summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-05-26 15:19:42 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-05-28 16:00:09 +0200
commit87a932120d5f146933ed3bcc16c0f47dab90fd4b (patch)
tree6022b3ff930f5931c39ff29f47259ffc704f4dd5 /include
parent9ea767cb568cef1b142190d2adb0e301baa382e2 (diff)
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 <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include')
-rw-r--r--include/svl/itemset.hxx8
-rw-r--r--include/svl/whiter.hxx22
2 files changed, 23 insertions, 7 deletions
diff --git a/include/svl/itemset.hxx b/include/svl/itemset.hxx
index 7b535fb93d6f..746ba8448afb 100644
--- a/include/svl/itemset.hxx
+++ b/include/svl/itemset.hxx
@@ -23,6 +23,7 @@
#include <cassert>
#include <cstddef>
#include <memory>
+#include <optional>
#include <utility>
#include <svl/svldllapi.h>
@@ -35,6 +36,7 @@ class SfxItemPool;
class SAL_WARN_UNUSED SVL_DLLPUBLIC SfxItemSet
{
friend class SfxItemIter;
+ friend class SfxWhichIter;
SfxItemPool* m_pPool; ///< pool that stores the items
const SfxItemSet* m_pParent; ///< derivation
@@ -223,6 +225,12 @@ public:
bool Equals(const SfxItemSet &, bool bComparePool) const;
void dumpAsXml(xmlTextWriterPtr pWriter) const;
+
+private:
+ SfxItemState GetItemStateImpl( sal_uInt16 nWhich,
+ bool bSrchInParent,
+ const SfxPoolItem **ppItem,
+ std::optional<sal_uInt16> oItemsOffsetHint) const;
};
inline void SfxItemSet::SetParent( const SfxItemSet* pNew )
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 <svl/svldllapi.h>
#include <svl/whichranges.hxx>
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: */