More pass string by ref to save copy
diff --git a/include/rive/animation/state_machine_instance.hpp b/include/rive/animation/state_machine_instance.hpp index 83e86a1..57b3e64 100644 --- a/include/rive/animation/state_machine_instance.hpp +++ b/include/rive/animation/state_machine_instance.hpp
@@ -38,7 +38,7 @@ void processEvent(Vec2D position, EventType hitEvent = EventType::updateHover); template <typename SMType, typename InstType> - InstType* getNamedInput(std::string name) const; + InstType* getNamedInput(const std::string& name) const; public: StateMachineInstance(const StateMachine* machine, ArtboardInstance* instance); @@ -57,9 +57,9 @@ size_t inputCount() const { return m_InputInstances.size(); } SMIInput* input(size_t index) const; - SMIBool* getBool(std::string name) const; - SMINumber* getNumber(std::string name) const; - SMITrigger* getTrigger(std::string name) const; + SMIBool* getBool(const std::string& name) const; + SMINumber* getNumber(const std::string& name) const; + SMITrigger* getTrigger(const std::string& name) const; std::string name() const;
diff --git a/src/animation/state_machine_instance.cpp b/src/animation/state_machine_instance.cpp index bfa61b4..fee23a4 100644 --- a/src/animation/state_machine_instance.cpp +++ b/src/animation/state_machine_instance.cpp
@@ -381,7 +381,7 @@ } template <typename SMType, typename InstType> -InstType* StateMachineInstance::getNamedInput(std::string name) const { +InstType* StateMachineInstance::getNamedInput(const std::string& name) const { for (const auto inst : m_InputInstances) { auto input = inst->input(); if (input->is<SMType>() && input->name() == name) { @@ -391,13 +391,13 @@ return nullptr; } -SMIBool* StateMachineInstance::getBool(std::string name) const { +SMIBool* StateMachineInstance::getBool(const std::string& name) const { return getNamedInput<StateMachineBool, SMIBool>(name); } -SMINumber* StateMachineInstance::getNumber(std::string name) const { +SMINumber* StateMachineInstance::getNumber(const std::string& name) const { return getNamedInput<StateMachineNumber, SMINumber>(name); } -SMITrigger* StateMachineInstance::getTrigger(std::string name) const { +SMITrigger* StateMachineInstance::getTrigger(const std::string& name) const { return getNamedInput<StateMachineTrigger, SMITrigger>(name); }