Merge "DALi Version 1.0.31" into tizen
[platform/core/uifw/dali-core.git] / dali / internal / common / owner-container.h
index 42f410a..9131616 100644 (file)
@@ -136,24 +136,29 @@ public:
    */
   void MoveFrom( OwnerContainer& source )
   {
-    // Optimisation for the case that this is empty
-    if( IsEmpty() )
+    typename Vector< T >::SizeType sourceCount = source.Count();
+    // if source is empty, nothing to move
+    if( sourceCount > 0u )
     {
-      VectorBase::Swap( source );
-    }
-    else
-    {
-      // make space for new items
-      Vector< T >::Reserve( VectorBase::Count() + source.Count() );
-      Iterator iter = source.Begin();
-      ConstIterator end = source.End();
-      for( ; iter != end; ++iter )
+      // Optimisation for the case that this is empty
+      if( IsEmpty() )
+      {
+        VectorBase::Swap( source );
+      }
+      else
       {
-        T pointer = *iter;
-        Vector< T >::PushBack( pointer );
+        // make space for new items
+        Vector< T >::Reserve( VectorBase::Count() + sourceCount );
+        Iterator iter = source.Begin();
+        ConstIterator end = source.End();
+        for( ; iter != end; ++iter )
+        {
+          T pointer = *iter;
+          Vector< T >::PushBack( pointer );
+        }
+        // cannot call Clear on OwnerContainer as that deletes the elements
+        source.Vector< T >::Clear();
       }
-      // cannot call Clear on OwnerContainer as that deletes the elements
-      source.Vector< T >::Clear();
     }
   }