sc/source/core/data/patattr.cxx | 72 +++++++--------------------------------- 1 file changed, 14 insertions(+), 58 deletions(-)
New commits: commit 944fbe89fd48fa7814c0b33ef22910e8221da9de Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Fri Sep 20 15:39:31 2024 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Fri Sep 20 21:03:32 2024 +0200 tdf#161562 Sluggish scrolling after saving and changing text color This reverts commit eb13c889c760cfe153d5b41188e218bdda797d52. "Speed up scrolling through large document with lots of patterns" Which seems (according to buovjaga testing) to be a pessimisation now. I can't reproduce this either way, so lets just revert it for now. Change-Id: I6b7f95173eb875d215f1192b3a7ca44014c50886 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173641 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx index b5814947b906..284759d1b965 100644 --- a/sc/source/core/data/patattr.cxx +++ b/sc/source/core/data/patattr.cxx @@ -47,8 +47,6 @@ #include <editeng/justifyitem.hxx> #include <svl/intitem.hxx> #include <svl/numformat.hxx> -#include <svl/whiter.hxx> -#include <svl/itemiter.hxx> #include <svl/zforlist.hxx> #include <vcl/outdev.hxx> #include <tools/fract.hxx> @@ -1506,66 +1504,24 @@ bool ScPatternAttr::CalcVisible() const return false; } -bool ScPatternAttr::IsVisibleEqual( const ScPatternAttr& rOther ) const +static bool OneEqual( const SfxItemSet& rSet1, const SfxItemSet& rSet2, sal_uInt16 nId ) { - // This method is hot, so we do an optimised comparison here, by - // walking the two itemsets in parallel, avoiding doing repeated searches. - auto IsInterestingWhich = [](sal_uInt16 n) - { - return n == ATTR_BORDER_TLBR || n == ATTR_BORDER_BLTR || n == ATTR_BACKGROUND - || n == ATTR_BORDER || n == ATTR_SHADOW; - }; - SfxWhichIter aIter1(GetItemSet()); - SfxWhichIter aIter2(rOther.GetItemSet()); - sal_uInt16 nWhich1 = aIter1.FirstWhich(); - sal_uInt16 nWhich2 = aIter2.FirstWhich(); - for (;;) - { - while (nWhich1 != nWhich2) - { - SfxWhichIter* pIterToIncrement; - sal_uInt16* pSmallerWhich; - if (nWhich1 == 0 || nWhich1 > nWhich2) - { - pSmallerWhich = &nWhich2; - pIterToIncrement = &aIter2; - } - else - { - pSmallerWhich = &nWhich1; - pIterToIncrement = &aIter1; - } - - if (IsInterestingWhich(*pSmallerWhich)) - { - // the iter with larger which has already passed this point, and has no interesting - // item available in the other - so indeed these are unequal - return false; - } - - *pSmallerWhich = pIterToIncrement->NextWhich(); - } + const SfxPoolItem* pItem1 = &rSet1.Get(nId); + const SfxPoolItem* pItem2 = &rSet2.Get(nId); + return ( pItem1 == pItem2 || *pItem1 == *pItem2 ); +} - // Here nWhich1 == nWhich2 +bool ScPatternAttr::IsVisibleEqual( const ScPatternAttr& rOther ) const +{ + const SfxItemSet& rThisSet = GetItemSet(); + const SfxItemSet& rOtherSet = rOther.GetItemSet(); - if (!nWhich1 /* && !nWhich2*/) - return true; + return OneEqual( rThisSet, rOtherSet, ATTR_BACKGROUND ) && + OneEqual( rThisSet, rOtherSet, ATTR_BORDER ) && + OneEqual( rThisSet, rOtherSet, ATTR_BORDER_TLBR ) && + OneEqual( rThisSet, rOtherSet, ATTR_BORDER_BLTR ) && + OneEqual( rThisSet, rOtherSet, ATTR_SHADOW ); - if (IsInterestingWhich(nWhich1)) - { - const SfxPoolItem* pItem1 = nullptr; - const SfxPoolItem* pItem2 = nullptr; - SfxItemState state1 = aIter1.GetItemState(true, &pItem1); - SfxItemState state2 = aIter2.GetItemState(true, &pItem2); - if (state1 != state2 - && (state1 < SfxItemState::DEFAULT || state2 < SfxItemState::DEFAULT)) - return false; - if (!SfxPoolItem::areSame(pItem1, pItem2)) - return false; - } - nWhich1 = aIter1.NextWhich(); - nWhich2 = aIter2.NextWhich(); - } //TODO: also here only check really visible values !!! }