From ec7ba61a6164c805f5a71b077715b7e1521a2d62 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 17 Apr 2019 15:19:25 +0200 Subject: simplify SfxPoolItemArray_Impl (tdf#81765 related) Since we want to look up items by pointer, just store them in a std::unordered_set, which allows fast find(). This dramatically simplifies most operations on this data structure. Fix a dodgy sd test that was relying on items with the same whichid being in the pool being in a certain order. Change-Id: I4d79fc718f95e3083a20788be1050fbe9fca7263 Reviewed-on: https://gerrit.libreoffice.org/70881 Tested-by: Jenkins Reviewed-by: Noel Grandin --- include/svl/itempool.hxx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/svl/itempool.hxx b/include/svl/itempool.hxx index e865c9396f37..f987cf15ae62 100644 --- a/include/svl/itempool.hxx +++ b/include/svl/itempool.hxx @@ -25,6 +25,7 @@ #include #include #include +#include class SfxBroadcaster; struct SfxItemPool_Impl; @@ -154,15 +155,19 @@ public: bool CheckItemInPool(const SfxPoolItem *) const; - const SfxPoolItem * GetItem2(sal_uInt16 nWhich, sal_uInt32 nSurrogate) const; - template const T* GetItem2( TypedWhichId nWhich, sal_uInt32 nSurrogate ) const - { return dynamic_cast(GetItem2(sal_uInt16(nWhich), nSurrogate)); } - + struct Item2Range + { + o3tl::sorted_vector::const_iterator m_begin; + o3tl::sorted_vector::const_iterator m_end; + o3tl::sorted_vector::const_iterator begin() { return m_begin; } + o3tl::sorted_vector::const_iterator end() { return m_end; } + }; const SfxPoolItem * GetItem2Default(sal_uInt16 nWhich) const; template const T* GetItem2Default( TypedWhichId nWhich ) const { return static_cast(GetItem2Default(sal_uInt16(nWhich))); } sal_uInt32 GetItemCount2(sal_uInt16 nWhich) const; + Item2Range GetItemSurrogates(sal_uInt16 nWhich) const; sal_uInt16 GetFirstWhich() const; sal_uInt16 GetLastWhich() const; -- cgit