From 7f6fbed9f195078ed63760f1206a328f38571ba8 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 26 May 2022 12:47:29 +0200 Subject: ofz#24932-1 walk ItemSets together in SfxItemSet::Set shaves 20% off the time of ./instdir/program/soffice.bin --calc --convert-to pdf ~/Downloads/ofz24932-1.rtf Change-Id: I85c8bdd51895d768c37d247f6bf07ce9183d1107 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135014 Tested-by: Jenkins Reviewed-by: Noel Grandin --- svl/source/items/itemset.cxx | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'svl') diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx index 7953cd922363..2d90ab16eac7 100644 --- a/svl/source/items/itemset.cxx +++ b/svl/source/items/itemset.cxx @@ -707,14 +707,29 @@ bool SfxItemSet::Set ClearItem(); if ( bDeep ) { - SfxWhichIter aIter(*this); - sal_uInt16 nWhich = aIter.FirstWhich(); - while ( nWhich ) + SfxWhichIter aIter1(*this); + SfxWhichIter aIter2(rSet); + sal_uInt16 nWhich1 = aIter1.FirstWhich(); + sal_uInt16 nWhich2 = aIter2.FirstWhich(); + for (;;) { + if (!nWhich1 || !nWhich2) + break; + if (nWhich1 > nWhich2) + { + nWhich2 = aIter2.NextWhich(); + continue; + } + if (nWhich1 < nWhich2) + { + nWhich1 = aIter1.NextWhich(); + continue; + } const SfxPoolItem* pItem; - if( SfxItemState::SET == rSet.GetItemState( nWhich, true, &pItem ) ) + if( SfxItemState::SET == rSet.GetItemState( nWhich1, true, &pItem ) ) bRet |= nullptr != Put( *pItem, pItem->Which() ); - nWhich = aIter.NextWhich(); + nWhich1 = aIter1.NextWhich(); + nWhich2 = aIter2.NextWhich(); } } else -- cgit