Fix AddUniformMapping() interface to take uniform name by value. 55/242855/3
authorSubhransu Mohanty <sub.mohanty@samsung.com>
Tue, 1 Sep 2020 09:24:16 +0000 (18:24 +0900)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Wed, 16 Sep 2020 15:17:31 +0000 (15:17 +0000)
this will avoid temporary string allocation.

Change-Id: I21e358150c3ac40496ae62c23562a77551e66acd

dali/internal/event/common/object-impl.cpp
dali/internal/event/common/object-impl.h
dali/internal/update/common/uniform-map.h

index e65d1f3..63b809c 100644 (file)
@@ -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<SceneGraph::UniformPropertyMapping> map =
+      new SceneGraph::UniformPropertyMapping(std::move(uniformName), propertyPtr);
     // Message takes ownership of Uniform map (and will delete it after copy)
     AddUniformMapMessage( const_cast<EventThreadServices&>(GetEventThreadServices()), sceneObject, map );
   }
index 41abd4a..5ef0f9e 100644 (file)
@@ -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
index 96e0fe9..b3afaa2 100644 (file)
@@ -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))
   {
   }