diff options
author | Chris Sherlock <chris.sherlock79@gmail.com> | 2022-06-25 10:44:56 +1000 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2022-11-13 13:43:50 +0100 |
commit | d773da0c083b4ee1cf1cccc2bd7846cbdbe37ed8 (patch) | |
tree | 770d9d3d0eedbb5c4eb3252d60cc16038840e3f3 /vcl/source/animate/Animation.cxx | |
parent | 75b569890a6630bb2a5b727c8567f7ea59ccb62e (diff) |
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 <quikee@gmail.com>
Diffstat (limited to 'vcl/source/animate/Animation.cxx')
-rw-r--r-- | vcl/source/animate/Animation.cxx | 11 |
1 files changed, 7 insertions, 4 deletions
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) |