From 341d251a454751df30e77625588608877f025da8 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Sat, 15 Feb 2025 21:12:30 -0500 Subject: [PATCH] BScrollBar: Avoid unnecessary invalidations when changing properties. * _UpdateThumbFrame() calls Invalidate() already, don't call it again in SetRange unnecessarily. * If the new and old thumb frames are the same, skip invalidation. Saves a lot of Invalidate() calls in HaikuDepot on building the "all packages" list especially. --- src/kits/interface/ScrollBar.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/kits/interface/ScrollBar.cpp b/src/kits/interface/ScrollBar.cpp index a5cc82cf98..e11cfda545 100644 --- a/src/kits/interface/ScrollBar.cpp +++ b/src/kits/interface/ScrollBar.cpp @@ -846,10 +846,8 @@ BScrollBar::SetRange(float min, float max) if (fValue < fMin || fValue > fMax) SetValue(fValue); - else { + else _UpdateThumbFrame(); - Invalidate(); - } } @@ -1255,7 +1253,7 @@ BScrollBar::_UpdateThumbFrame() fPrivateData->fThumbFrame.OffsetBy(offset, 0.0); } - if (Window() != NULL) { + if (Window() != NULL && fPrivateData->fThumbFrame != oldFrame) { BRect invalid = oldFrame.IsValid() ? oldFrame | fPrivateData->fThumbFrame : fPrivateData->fThumbFrame;