diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2019-05-05 18:27:01 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-05-06 07:17:20 +0200 |
commit | 668de126d9217636ff8592928bb581ecd59db66f (patch) | |
tree | 4f2ae24ee2ca042bedffd6bcad5b6ada4e7cd2e1 /svl | |
parent | d6e8e41c22023bc15cc4c9659b33c1cc3d6edb75 (diff) |
improve assert in SfxItemPooL::Put
need to check for ownership passing in both variants of the loop, so
just move it into the common block below.
Change-Id: I75929377dd64df722a8ef040b5f714346417475d
Reviewed-on: https://gerrit.libreoffice.org/71826
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svl')
-rw-r--r-- | svl/source/items/itempool.cxx | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx index 8df891a247f5..7c6f746ba319 100644 --- a/svl/source/items/itempool.cxx +++ b/svl/source/items/itempool.cxx @@ -620,9 +620,8 @@ const SfxPoolItem& SfxItemPool::PutImpl( const SfxPoolItem& rItem, sal_uInt16 nW // if is already in a pool, then it is worth checking if it is in this one. if ( IsPooledItem(&rItem) ) { - auto it = rItemArr.find(const_cast<SfxPoolItem *>(&rItem)); - // 1. search for an identical pointer in the pool + auto it = rItemArr.find(const_cast<SfxPoolItem *>(&rItem)); if (it != rItemArr.end()) { AddRef(rItem); @@ -637,10 +636,7 @@ const SfxPoolItem& SfxItemPool::PutImpl( const SfxPoolItem& rItem, sal_uInt16 nW { pFoundItem = rItemArr.findByLessThan(&rItem); if (pFoundItem) - { assert(*pFoundItem == rItem); - AddRef(*pFoundItem); - } } else { @@ -649,15 +645,14 @@ const SfxPoolItem& SfxItemPool::PutImpl( const SfxPoolItem& rItem, sal_uInt16 nW if (**itr == rItem) { pFoundItem = *itr; - assert((!bPassingOwnership || (&rItem != *itr)) && "can't be passing ownership and have the item already in the pool"); - AddRef(**itr); break; } } } - if (pFoundItem) { + assert((!bPassingOwnership || (&rItem != pFoundItem)) && "can't be passing ownership and have the item already in the pool"); + AddRef(*pFoundItem); if (bPassingOwnership) delete &rItem; return *pFoundItem; |