From c30fbfba96ab2d8d6229d7f4010718bd2b3c97d9 Mon Sep 17 00:00:00 2001 From: Jochen Nitschke Date: Thu, 22 Sep 2016 13:27:55 +0200 Subject: tdf#75757 remove inheritance from std::vector Change-Id: Ief06d3ea0288e8ebf34f2f67f3d1dfc9405b6d49 Reviewed-on: https://gerrit.libreoffice.org/29180 Reviewed-by: Jochen Nitschke Tested-by: Jochen Nitschke --- svl/source/inc/poolio.hxx | 13 +++++++++++-- svl/source/items/poolio.cxx | 10 ++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/svl/source/inc/poolio.hxx b/svl/source/inc/poolio.hxx index 627fd6ba62ab..0dd561e30346 100644 --- a/svl/source/inc/poolio.hxx +++ b/svl/source/inc/poolio.hxx @@ -68,11 +68,12 @@ typedef std::shared_ptr< SfxPoolVersion_Impl > SfxPoolVersion_ImplPtr; * often search linearly to ensure uniqueness. If they are * non-poolable we maintain an (often large) list of pointers. */ -struct SfxPoolItemArray_Impl: public SfxPoolItemArrayBase_Impl +struct SfxPoolItemArray_Impl { typedef std::vector FreeList; typedef std::unordered_map PoolItemPtrToIndexMap; - +private: + std::vector maPoolItemVector; public: /// Track list of indices into our array that contain an empty slot FreeList maFree; @@ -80,6 +81,14 @@ public: PoolItemPtrToIndexMap maPtrToIndex; SfxPoolItemArray_Impl () {} + SfxPoolItem*& operator[](size_t n) {return maPoolItemVector[n];} + std::vector::iterator begin() {return maPoolItemVector.begin();} + std::vector::iterator end() {return maPoolItemVector.end();} + /// clear array of PoolItem variants after all PoolItems are deleted + /// or all ref counts are decreased + void clear(); + size_t size() const {return maPoolItemVector.size();} + void push_back(SfxPoolItem* pItem) {maPoolItemVector.push_back(pItem);} /// re-build the list of free slots and hash from clean void SVL_DLLPUBLIC ReHash(); diff --git a/svl/source/items/poolio.cxx b/svl/source/items/poolio.cxx index ec236900a532..43e401dcc1ff 100644 --- a/svl/source/items/poolio.cxx +++ b/svl/source/items/poolio.cxx @@ -30,6 +30,16 @@ #include #include +/// clear array of PoolItem variants +/// after all PoolItems are deleted +/// or all ref counts are decreased +void SfxPoolItemArray_Impl::clear() +{ + maPoolItemVector.clear(); + maFree.clear(); + maPtrToIndex.clear(); +} + /** * Returns the that is being saved. * This should only be used in very exceptional cases e.g. -- cgit