From cfb03652db780fc19af98a933e8a68fc3b204546 Mon Sep 17 00:00:00 2001 From: Subhransu Mohanty Date: Tue, 1 Sep 2020 18:24:16 +0900 Subject: [PATCH] Fix AddUniformMapping() interface to take uniform name by value. this will avoid temporary string allocation. Change-Id: I21e358150c3ac40496ae62c23562a77551e66acd --- dali/internal/event/common/object-impl.cpp | 5 +++-- dali/internal/event/common/object-impl.h | 2 +- dali/internal/update/common/uniform-map.h | 8 ++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/dali/internal/event/common/object-impl.cpp b/dali/internal/event/common/object-impl.cpp index e65d1f3..63b809c 100644 --- a/dali/internal/event/common/object-impl.cpp +++ b/dali/internal/event/common/object-impl.cpp @@ -761,7 +761,7 @@ void Object::NotifyPropertyAnimation( Animation& animation, Property::Index inde } } -void Object::AddUniformMapping( Property::Index propertyIndex, const std::string& uniformName ) const +void Object::AddUniformMapping(Property::Index propertyIndex, std::string uniformName) const { // Get the address of the property if it's a scene property const PropertyInputImpl* propertyPtr = GetSceneObjectInputProperty( propertyIndex ); @@ -789,7 +789,8 @@ void Object::AddUniformMapping( Property::Index propertyIndex, const std::string { const SceneGraph::PropertyOwner& sceneObject = GetSceneObject(); - OwnerPointer< SceneGraph::UniformPropertyMapping > map = new SceneGraph::UniformPropertyMapping( uniformName, propertyPtr ); + OwnerPointer map = + new SceneGraph::UniformPropertyMapping(std::move(uniformName), propertyPtr); // Message takes ownership of Uniform map (and will delete it after copy) AddUniformMapMessage( const_cast(GetEventThreadServices()), sceneObject, map ); } diff --git a/dali/internal/event/common/object-impl.h b/dali/internal/event/common/object-impl.h index 41abd4a..5ef0f9e 100644 --- a/dali/internal/event/common/object-impl.h +++ b/dali/internal/event/common/object-impl.h @@ -270,7 +270,7 @@ public: * @param propertyIndex index of the property * @param uniformName name of the uniform (same as property name) */ - void AddUniformMapping( Property::Index propertyIndex, const std::string& uniformName ) const; + void AddUniformMapping(Property::Index propertyIndex, std::string uniformName) const; /** * Removes uniform mapping for given property diff --git a/dali/internal/update/common/uniform-map.h b/dali/internal/update/common/uniform-map.h index 96e0fe9..b3afaa2 100644 --- a/dali/internal/update/common/uniform-map.h +++ b/dali/internal/update/common/uniform-map.h @@ -45,10 +45,10 @@ public: /** * Constructor */ - UniformPropertyMapping( const std::string& theUniformName, const PropertyInputImpl* thePropertyPtr ) - : propertyPtr( thePropertyPtr ), - uniformName( theUniformName ), - uniformNameHash( Dali::CalculateHash( theUniformName ) ) + UniformPropertyMapping(std::string theUniformName, const PropertyInputImpl* thePropertyPtr) + : propertyPtr(thePropertyPtr), + uniformName(std::move(theUniformName)), + uniformNameHash(Dali::CalculateHash(theUniformName)) { } -- 2.7.4