From: Subhransu Mohanty Date: Wed, 2 Dec 2020 05:48:17 +0000 (+0900) Subject: Optimize Orphan animator Cleanup. X-Git-Tag: dali_2.0.4~3^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-core.git;a=commitdiff_plain;h=2d970aead71b5ec203887d14f5cb36ae1f31aec1 Optimize Orphan animator Cleanup. 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 --- diff --git a/dali/internal/update/animation/scene-graph-animation.cpp b/dali/internal/update/animation/scene-graph-animation.cpp index 10a735f..1ac2e43 100644 --- a/dali/internal/update/animation/scene-graph-animation.cpp +++ b/dali/internal/update/animation/scene-graph-animation.cpp @@ -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