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.
This commit is contained in:
Lioncash 2023-12-12 13:50:44 -05:00
parent 2c6bf2d224
commit ea71a76ea9
2 changed files with 6 additions and 6 deletions

View File

@ -600,7 +600,7 @@ private:
std::unique_ptr<Expression> m_rhs;
};
std::shared_ptr<Device> ControlEnvironment::FindDevice(ControlQualifier qualifier) const
std::shared_ptr<Device> ControlEnvironment::FindDevice(const ControlQualifier& qualifier) const
{
if (qualifier.has_device)
return container.FindDevice(qualifier.device_qualifier);
@ -608,7 +608,7 @@ std::shared_ptr<Device> 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> 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> device = FindDevice(qualifier);
if (!device)

View File

@ -150,9 +150,9 @@ public:
{
}
std::shared_ptr<Core::Device> FindDevice(ControlQualifier qualifier) const;
Core::Device::Input* FindInput(ControlQualifier qualifier) const;
Core::Device::Output* FindOutput(ControlQualifier qualifier) const;
std::shared_ptr<Core::Device> 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<ControlState> GetVariablePtr(const std::string& name);