vcl/source/animate/Animation.cxx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
New commits: commit d773da0c083b4ee1cf1cccc2bd7846cbdbe37ed8 Author: Chris Sherlock <chris.sherloc...@gmail.com> AuthorDate: Sat Jun 25 10:44:56 2022 +1000 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Sun Nov 13 13:43:50 2022 +0100 vcl: small optimization determining if any renderers are active Currently we look at every renderer to see if it is paused. However, you can think of this differently - instead of using a universal quantifier we can actually use an existential quantifier - if even one renderer is not paused, then we can say that not every renderer is paused - thus no global pause. Hence switch to any_of(), which stops the loop at the first instance of a non-paused renderer. Change-Id: I3b35bc41e86432374e4bc5fae0a2927ec8cc2309 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136412 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/vcl/source/animate/Animation.cxx b/vcl/source/animate/Animation.cxx index c6547f9e7852..e1bd5ba042fc 100644 --- a/vcl/source/animate/Animation.cxx +++ b/vcl/source/animate/Animation.cxx @@ -367,7 +367,7 @@ IMPL_LINK_NOARG(Animation, ImplTimeoutHdl, Timer*, void) if (nAnimCount) { - bool bGlobalPause = false; + bool bIsAnyRendererActive = true; if (maNotifyLink.IsSet()) { @@ -381,8 +381,9 @@ IMPL_LINK_NOARG(Animation, ImplTimeoutHdl, Timer*, void) maRenderers.erase(removeStart, maRenderers.cend()); // check if every remaining view is paused - bGlobalPause = std::all_of(maRenderers.cbegin(), maRenderers.cend(), - [](const auto& pRenderer) { return pRenderer->isPaused(); }); + bIsAnyRendererActive + = std::any_of(maRenderers.cbegin(), maRenderers.cend(), + [](const auto& pRenderer) { return !pRenderer->isPaused(); }); // reset marked state std::for_each(maRenderers.cbegin(), maRenderers.cend(), @@ -391,13 +392,15 @@ IMPL_LINK_NOARG(Animation, ImplTimeoutHdl, Timer*, void) if (maRenderers.empty()) Stop(); - else if (bGlobalPause) + else if (!bIsAnyRendererActive) ImplRestartTimer(10); else RenderNextFrameInAllRenderers(); } else + { Stop(); + } } bool Animation::Insert(const AnimationFrame& rStepBmp)