Optimize Orphan animator Cleanup. 63/248763/1
authorSubhransu Mohanty <sub.mohanty@samsung.com>
Wed, 2 Dec 2020 05:48:17 +0000 (14:48 +0900)
committerSubhransu Mohanty <sub.mohanty@samsung.com>
Wed, 2 Dec 2020 05:51:29 +0000 (14:51 +0900)
keep a cleanup falg and update it if cleanup is required.
and then cleanup at onece all the orphan animators.

when there are no orphan animators we don't have to walk the animators twice.

Change-Id: I9c2f7f2bef9a7655481743a22abdf366d8b12f21

dali/internal/update/animation/scene-graph-animation.cpp

index 10a735f..1ac2e43 100644 (file)
@@ -430,15 +430,17 @@ void Animation::UpdateAnimators( BufferIndex bufferIndex, bool bake, bool animat
   const Vector2 playRange( mPlayRange * mDurationSeconds );
   float elapsedSecondsClamped = Clamp( mElapsedSeconds, playRange.x, playRange.y );
 
-  //Remove animators whose PropertyOwner has been destroyed
-  mAnimators.Erase(std::remove_if(mAnimators.begin(),
-                                  mAnimators.end(),
-                                  [](auto animator) { return animator->Orphan(); }),
-                   mAnimators.end());
+  bool cleanup = false;
 
   //Loop through all animators
   for(auto& animator : mAnimators)
   {
+    if(animator->Orphan())
+    {
+      cleanup = true;
+      continue;
+    }
+
     bool applied(true);
     if(animator->IsEnabled())
     {
@@ -477,6 +479,15 @@ void Animation::UpdateAnimators( BufferIndex bufferIndex, bool bake, bool animat
       INCREASE_COUNTER(PerformanceMonitor::ANIMATORS_APPLIED);
     }
   }
+
+  if(cleanup)
+  {
+    //Remove animators whose PropertyOwner has been destroyed
+    mAnimators.Erase(std::remove_if(mAnimators.begin(),
+                                    mAnimators.end(),
+                                    [](auto& animator) { return animator->Orphan(); }),
+                     mAnimators.end());
+  }
 }
 
 } // namespace SceneGraph