From ea71a76ea965d03ccc600ce070a58b9c335fe63f Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 12 Dec 2023 13:50:44 -0500 Subject: [PATCH] ExpressionParser: Pass control qualifiers by const reference These aren't necessarily cheap to copy, since a control qualifier will have around 3 std::strings inside of it, so passing by value can churn allocations a little bit. --- .../Core/InputCommon/ControlReference/ExpressionParser.cpp | 6 +++--- Source/Core/InputCommon/ControlReference/ExpressionParser.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/Core/InputCommon/ControlReference/ExpressionParser.cpp b/Source/Core/InputCommon/ControlReference/ExpressionParser.cpp index c93dcc5c3d..4463118d39 100644 --- a/Source/Core/InputCommon/ControlReference/ExpressionParser.cpp +++ b/Source/Core/InputCommon/ControlReference/ExpressionParser.cpp @@ -600,7 +600,7 @@ private: std::unique_ptr m_rhs; }; -std::shared_ptr ControlEnvironment::FindDevice(ControlQualifier qualifier) const +std::shared_ptr ControlEnvironment::FindDevice(const ControlQualifier& qualifier) const { if (qualifier.has_device) return container.FindDevice(qualifier.device_qualifier); @@ -608,7 +608,7 @@ std::shared_ptr ControlEnvironment::FindDevice(ControlQualifier qualifie return container.FindDevice(default_device); } -Device::Input* ControlEnvironment::FindInput(ControlQualifier qualifier) const +Device::Input* ControlEnvironment::FindInput(const ControlQualifier& qualifier) const { const std::shared_ptr device = FindDevice(qualifier); if (!device) @@ -617,7 +617,7 @@ Device::Input* ControlEnvironment::FindInput(ControlQualifier qualifier) const return device->FindInput(qualifier.control_name); } -Device::Output* ControlEnvironment::FindOutput(ControlQualifier qualifier) const +Device::Output* ControlEnvironment::FindOutput(const ControlQualifier& qualifier) const { const std::shared_ptr device = FindDevice(qualifier); if (!device) diff --git a/Source/Core/InputCommon/ControlReference/ExpressionParser.h b/Source/Core/InputCommon/ControlReference/ExpressionParser.h index 405445b8a0..bc39762127 100644 --- a/Source/Core/InputCommon/ControlReference/ExpressionParser.h +++ b/Source/Core/InputCommon/ControlReference/ExpressionParser.h @@ -150,9 +150,9 @@ public: { } - std::shared_ptr FindDevice(ControlQualifier qualifier) const; - Core::Device::Input* FindInput(ControlQualifier qualifier) const; - Core::Device::Output* FindOutput(ControlQualifier qualifier) const; + std::shared_ptr FindDevice(const ControlQualifier& qualifier) const; + Core::Device::Input* FindInput(const ControlQualifier& qualifier) const; + Core::Device::Output* FindOutput(const ControlQualifier& qualifier) const; // Returns an existing variable by the specified name if already existing. Creates it otherwise. std::shared_ptr GetVariablePtr(const std::string& name);