From 87a932120d5f146933ed3bcc16c0f47dab90fd4b Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 26 May 2022 15:19:42 +0200 Subject: ofz#24932-1 speed up GetItemState when iterating by having SfxWhichIter track the current position in the m_ppItems table, which means GetItemState does not need to traverse the ranges table to find the item position. shaves 75% off the time of ./instdir/program/soffice.bin --calc --convert-to pdf ~/Downloads/ofz24932-1.rtf Change-Id: Ib5fe61c75ca05bc2f1932e84b57ccfa55f8b7f74 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135023 Tested-by: Jenkins Reviewed-by: Noel Grandin --- include/svl/whiter.hxx | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'include/svl/whiter.hxx') diff --git a/include/svl/whiter.hxx b/include/svl/whiter.hxx index c4a49a06b622..df8c6fea79f2 100644 --- a/include/svl/whiter.hxx +++ b/include/svl/whiter.hxx @@ -16,19 +16,27 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_SVL_WHITER_HXX -#define INCLUDED_SVL_WHITER_HXX +#pragma once #include #include class SfxItemSet; +class SfxPoolItem; +enum class SfxItemState; +/** + * Iterates over the which ids and the pool items arrays together (which are stored in parallel arrays). + * Primarily so that we can call GetItemSet on the SfxItemSet and pass in a hint, which avoids + * searching the array the SfxItemSet, which speeds up GetItemState greatly. + */ class SVL_DLLPUBLIC SfxWhichIter { - const WhichRangesContainer& pStart; - const WhichPair* pRanges; - sal_uInt16 nOffset; + const SfxItemSet& m_rItemSet; + const WhichPair* m_pCurrentWhichPair; + sal_uInt16 m_nOffsetFromStartOfCurrentWhichPair; + /// Offset into m_ppItems array in SfxItemSet + sal_uInt16 m_nItemsOffset; public: SfxWhichIter(const SfxItemSet& rSet); @@ -36,8 +44,8 @@ public: sal_uInt16 GetCurWhich() const; sal_uInt16 NextWhich(); sal_uInt16 FirstWhich(); + SfxItemState GetItemState(bool bSrchInParent = true, + const SfxPoolItem** ppItem = nullptr) const; }; -#endif - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit