Removal of unnecessary use of std::set, part I 11/28811/1
authorKimmo Hoikka <kimmo.hoikka@samsung.com>
Thu, 16 Oct 2014 09:33:33 +0000 (10:33 +0100)
committerKimmo Hoikka <kimmo.hoikka@samsung.com>
Thu, 16 Oct 2014 09:33:33 +0000 (10:33 +0100)
[Problem] binary size
[Cause] use of too many container types
[Solution] stop using set

Change-Id: I26e70c77733eb84086ce04112e7d65501aae01bd

dali/internal/event/animation/animation-playlist.cpp
dali/internal/event/animation/animation-playlist.h
dali/internal/event/common/object-registry-impl.cpp
dali/internal/event/common/object-registry-impl.h
dali/internal/event/common/property-notification-manager.cpp
dali/internal/event/common/property-notification-manager.h
dali/internal/render/shaders/program.h
dali/public-api/dali-core.h

index 7e27e55..866a400 100644 (file)
@@ -46,25 +46,32 @@ AnimationPlaylist::~AnimationPlaylist()
 
 void AnimationPlaylist::AnimationCreated( Animation& animation )
 {
-  mAnimations.insert( &animation );
+  mAnimations.PushBack( &animation );
 }
 
 void AnimationPlaylist::AnimationDestroyed( Animation& animation )
 {
-  std::set< Animation* >::iterator iter = find( mAnimations.begin(), mAnimations.end(), &animation );
-  DALI_ASSERT_ALWAYS( iter != mAnimations.end() && "Animation not found" );
+  Dali::Vector< Animation* >::Iterator iter = std::find( mAnimations.Begin(), mAnimations.End(), &animation );
+  DALI_ASSERT_ALWAYS( iter != mAnimations.End() && "Animation not found" );
 
-  mAnimations.erase( iter );
+  mAnimations.Remove( iter );
 }
 
 void AnimationPlaylist::OnPlay( Animation& animation )
 {
-  mPlaylist.insert( Dali::Animation(&animation) );
+  mPlaylist.push_back( Dali::Animation(&animation) );
 }
 
 void AnimationPlaylist::OnClear( Animation& animation )
 {
-  mPlaylist.erase( Dali::Animation(&animation) );
+  std::vector< Dali::Animation >::iterator iter = std::find( mPlaylist.begin(), mPlaylist.end(), Dali::Animation(&animation) );
+  std::vector< Dali::Animation >::iterator last = mPlaylist.end();
+  if( iter != last )
+  {
+    --last; // move to real last
+    std::swap( *iter, *last ); // swap
+    mPlaylist.resize( mPlaylist.size() - 1u );
+  }
 }
 
 void AnimationPlaylist::NotifyCompleted()
@@ -73,7 +80,7 @@ void AnimationPlaylist::NotifyCompleted()
 
   // Since animations can be unreferenced during the signal emissions, iterators into animationPointers may be invalidated.
   // First copy and reference the finished animations, then emit signals
-  for ( std::set< Animation* >::iterator iter = mAnimations.begin(); iter != mAnimations.end(); ++iter )
+  for ( Dali::Vector< Animation* >::Iterator iter = mAnimations.Begin(); iter != mAnimations.End(); ++iter )
   {
     Animation* animation = *iter;
 
@@ -83,7 +90,8 @@ void AnimationPlaylist::NotifyCompleted()
 
       // The animation may be present in mPlaylist - remove if necessary
       // Note that the animation "Finish" signal is emitted after Stop() has been called
-      mPlaylist.erase( Dali::Animation(animation) );
+      std::vector< Dali::Animation >::iterator iter = std::find( mPlaylist.begin(), mPlaylist.end(), Dali::Animation(animation) );
+      mPlaylist.erase( iter );
     }
   }
 
index ced67a7..504bc5f 100644 (file)
@@ -20,7 +20,8 @@
 
 // INTERNAL INCLUDES
 #include <dali/public-api/animation/animation.h>
-#include <dali/public-api/common/set-wrapper.h>
+#include <dali/public-api/common/dali-vector.h>
+#include <dali/public-api/common/vector-wrapper.h>
 #include <dali/internal/event/common/complete-notification-interface.h>
 
 namespace Dali
@@ -94,8 +95,8 @@ private: // from CompleteNotificationInterface
 
 private:
 
-  std::set< Animation* > mAnimations; ///< All existing animations (not referenced)
-  std::set< Dali::Animation > mPlaylist; ///< The currently playing animations (reference counted)
+  Dali::Vector< Animation* > mAnimations; ///< All existing animations (not owned)
+  std::vector< Dali::Animation > mPlaylist; ///< The currently playing animations (owned through handle)
 
 };
 
index 906a200..65f605f 100644 (file)
@@ -46,14 +46,6 @@ ObjectRegistry::~ObjectRegistry()
 
 void ObjectRegistry::RegisterObject( Dali::BaseObject* object )
 {
-  // Assert than an object is only registered once
-  DALI_ASSERT_DEBUG( mDebugRegistry.end() == mDebugRegistry.find( object ) );
-
-#ifdef DEBUG_ENABLED
-  // This allows us to assert that an object is only registered once (debug builds only)
-  mDebugRegistry.insert( object );
-#endif // DEBUG_ENABLED
-
   if ( !mObjectCreatedSignalV2.Empty() )
   {
     Dali::BaseHandle handle( object );
@@ -63,11 +55,6 @@ void ObjectRegistry::RegisterObject( Dali::BaseObject* object )
 
 void ObjectRegistry::UnregisterObject( Dali::BaseObject* object )
 {
-#ifdef DEBUG_ENABLED
-  // This allows us to assert that an object is only registered once (debug builds only)
-  mDebugRegistry.erase( object );
-#endif // DEBUG_ENABLED
-
   mObjectDestroyedSignalV2.Emit( object );
 }
 
index c85144c..3133b83 100644 (file)
@@ -19,9 +19,6 @@
  */
 
 // INTERNAL INCLUDES
-#ifdef DEBUG_ENABLED
-#include <dali/public-api/common/set-wrapper.h>
-#endif
 #include <dali/public-api/object/ref-object.h>
 #include <dali/public-api/object/object-registry.h>
 #include <dali/public-api/object/base-object.h>
@@ -121,10 +118,6 @@ private:
   Dali::ObjectRegistry::ObjectCreatedSignalV2 mObjectCreatedSignalV2;
   Dali::ObjectRegistry::ObjectDestroyedSignalV2 mObjectDestroyedSignalV2;
 
-#ifdef DEBUG_ENABLED
-  std::set< Dali::BaseObject* > mDebugRegistry; ///< This allows us to assert that an object is only registered once (debug builds only)
-#endif
-
 };
 
 } // namespace Internal
index 235fbd4..54980c8 100644 (file)
  *
  */
 
-// INTERNAL INCLUDES
+// CLASS HEADER
 #include <dali/internal/event/common/property-notification-manager.h>
+
+// INTERNAL INCLUDES
 #include <dali/internal/event/common/property-notification-impl.h>
+#include <dali/internal/common/message.h>
 
 namespace Dali
 {
@@ -36,21 +39,21 @@ PropertyNotificationManager::~PropertyNotificationManager()
 
 void PropertyNotificationManager::PropertyNotificationCreated( PropertyNotification& propertyNotification )
 {
-  mPropertyNotifications.insert( &propertyNotification );
+  mPropertyNotifications.PushBack( &propertyNotification );
 }
 
 void PropertyNotificationManager::PropertyNotificationDestroyed( PropertyNotification& propertyNotification )
 {
-  std::set< PropertyNotification* >::iterator iter = std::find( mPropertyNotifications.begin(), mPropertyNotifications.end(), &propertyNotification );
-  DALI_ASSERT_ALWAYS( iter != mPropertyNotifications.end() && "PropertyNotification not found" );
+  Dali::Vector< PropertyNotification* >::Iterator iter = std::find( mPropertyNotifications.Begin(), mPropertyNotifications.End(), &propertyNotification );
+  DALI_ASSERT_ALWAYS( iter != mPropertyNotifications.End() && "PropertyNotification not found" );
 
-  mPropertyNotifications.erase( iter );
+  mPropertyNotifications.Remove( iter );
 }
 
 void PropertyNotificationManager::NotifyProperty( SceneGraph::PropertyNotification* propertyNotification, bool validity )
 {
-  std::set< PropertyNotification* >::iterator iter = mPropertyNotifications.begin();
-  std::set< PropertyNotification* >::iterator endIter = mPropertyNotifications.end();
+  Dali::Vector< PropertyNotification* >::Iterator iter = mPropertyNotifications.Begin();
+  const Dali::Vector< PropertyNotification* >::Iterator endIter = mPropertyNotifications.End();
 
   // walk the collection of PropertyNotifications
   for( ; iter != endIter; ++iter )
index 97fc308..a5eef94 100644 (file)
@@ -19,8 +19,7 @@
  */
 
 // INTERNAL INCLUDES
-#include <dali/public-api/common/set-wrapper.h>
-#include <dali/internal/common/message.h>
+#include <dali/public-api/common/dali-vector.h>
 #include <dali/internal/event/common/property-notifier.h>
 
 namespace Dali
@@ -84,7 +83,7 @@ private:
 
 private:
 
-  std::set< PropertyNotification* > mPropertyNotifications; ///< All existing PropertyNotifications (not referenced)
+  Dali::Vector< PropertyNotification* > mPropertyNotifications; ///< All existing PropertyNotifications (not owned)
 
 };
 
index 341abb9..ab7cc6e 100644 (file)
@@ -23,7 +23,6 @@
 
 // INTERNAL INCLUDES
 #include <dali/public-api/common/vector-wrapper.h>
-#include <dali/public-api/common/set-wrapper.h>
 #include <dali/public-api/object/ref-object.h>
 #include <dali/internal/render/gl-resources/context.h>
 #include <dali/integration-api/resource-cache.h>
index d9ddbb7..3fdd352 100644 (file)
@@ -53,8 +53,6 @@
 #include <dali/public-api/common/intrusive-ptr.h>
 #include <dali/public-api/common/light.h>
 #include <dali/public-api/common/loading-state.h>
-#include <dali/public-api/common/map-wrapper.h>
-#include <dali/public-api/common/set-wrapper.h>
 #include <dali/public-api/common/stage.h>
 #include <dali/public-api/common/vector-wrapper.h>
 #include <dali/public-api/common/view-mode.h>