diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-01-23 10:38:15 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-01-23 13:19:56 +0200 |
commit | 00aa9f622c29aecc6bb9c5ee4b3aa35a9afb095d (patch) | |
tree | 6b10baae17781ad810d0f7b7c08cc30945fa6246 /include | |
parent | b0730ff656848f005838b10bef0cf88f5ac0ba32 (diff) |
Revert "used std::map in SfxItemSet"
This reverts commit 2757ee9fe610e253e4ccc37423fa420004d0f388.
Besides causing a performance regression, I now notice that
there is code in SW that relies on iterating over two different
SfxItemSet's in parallel, and assumes that missing items are
returned as nullptr, which is not the case for my std::map based
change.
Change-Id: I2b1110350fe4c4b74e5508558e9661ef1e1a103e
Diffstat (limited to 'include')
-rw-r--r-- | include/svl/itemiter.hxx | 32 | ||||
-rw-r--r-- | include/svl/itemset.hxx | 10 |
2 files changed, 25 insertions, 17 deletions
diff --git a/include/svl/itemiter.hxx b/include/svl/itemiter.hxx index b68730f245d6..30b6bd13d00d 100644 --- a/include/svl/itemiter.hxx +++ b/include/svl/itemiter.hxx @@ -21,7 +21,6 @@ #include <svl/svldllapi.h> #include <svl/itemset.hxx> -#include <vector> class SfxPoolItem; class SfxItemSet; @@ -29,23 +28,32 @@ class SfxItemPool; class SVL_DLLPUBLIC SfxItemIter { - const SfxItemSet& m_rSet; - std::vector<sal_uInt16> m_keys; - std::vector<sal_uInt16>::const_iterator m_iter; + const SfxItemSet& m_rSet; + sal_uInt16 m_nStart; + sal_uInt16 m_nEnd; + sal_uInt16 m_nCurrent; public: SfxItemIter( const SfxItemSet& rSet ); ~SfxItemIter(); /// get item, or null if no items - SfxPoolItem const * FirstItem(); - SfxPoolItem const * GetCurItem(); - SfxPoolItem const * NextItem(); - - bool IsAtEnd() const; - sal_uInt16 GetCurWhich() const { return *m_iter; } - sal_uInt16 GetFirstWhich() const { return *m_keys.begin(); } - sal_uInt16 GetLastWhich() const { return *m_keys.rbegin(); } + const SfxPoolItem* FirstItem() + { + m_nCurrent = m_nStart; + return m_rSet.m_nCount ? *(m_rSet.m_pItems + m_nCurrent) : nullptr; + } + const SfxPoolItem* GetCurItem() + { + return m_rSet.m_nCount ? *(m_rSet.m_pItems + m_nCurrent) : nullptr; + } + const SfxPoolItem* NextItem(); + + bool IsAtEnd() const { return m_nCurrent == m_nEnd; } + + sal_uInt16 GetCurPos() const { return m_nCurrent; } + sal_uInt16 GetFirstPos() const { return m_nStart; } + sal_uInt16 GetLastPos() const { return m_nEnd; } }; #endif diff --git a/include/svl/itemset.hxx b/include/svl/itemset.hxx index 8c1ebd5b8109..dccebd2b23b3 100644 --- a/include/svl/itemset.hxx +++ b/include/svl/itemset.hxx @@ -23,13 +23,12 @@ #include <cstdarg> #include <svl/poolitem.hxx> -#include <map> class SfxItemPool; class SfxPoolItem; class SvStream; -typedef std::map<sal_uInt16, SfxPoolItem const *> SfxItemMap; +typedef SfxPoolItem const** SfxItemArray; class SAL_WARN_UNUSED SVL_DLLPUBLIC SfxItemSet { @@ -37,8 +36,9 @@ class SAL_WARN_UNUSED SVL_DLLPUBLIC SfxItemSet SfxItemPool* m_pPool; ///< pool that stores the items const SfxItemSet* m_pParent; ///< derivation - SfxItemMap m_aItems; ///< array of items + SfxItemArray m_pItems; ///< array of items sal_uInt16* m_pWhichRanges; ///< array of Which Ranges + sal_uInt16 m_nCount; ///< number of items friend class SfxItemPoolCache; friend class SfxAllItemSet; @@ -50,7 +50,7 @@ private: SVL_DLLPRIVATE void InitRanges_Impl(sal_uInt16 nWh1, sal_uInt16 nWh2); public: - SfxItemMap const & GetItems_Impl() const { return m_aItems; } + SfxItemArray GetItems_Impl() const { return m_pItems; } private: const SfxItemSet& operator=(const SfxItemSet &) = delete; @@ -73,7 +73,7 @@ public: virtual SfxItemSet * Clone(bool bItems = true, SfxItemPool *pToPool = nullptr) const; // Get number of items - sal_uInt16 Count() const { return m_aItems.size(); } + sal_uInt16 Count() const { return m_nCount; } sal_uInt16 TotalCount() const; const SfxPoolItem& Get( sal_uInt16 nWhich, bool bSrchInParent = true ) const; |