From 21e977167664e8b5ae86c712b08fde045af7fafd Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Tue, 24 Jun 2014 13:56:51 +0100 Subject: Improve SfxItemPool documentation. Change-Id: If5a555dae067d023c9dd1fd8e0409ca327739f08 --- svl/source/items/itempool.cxx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'svl') diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx index d18b1226a33e..1990d4639e9f 100644 --- a/svl/source/items/itempool.cxx +++ b/svl/source/items/itempool.cxx @@ -711,6 +711,9 @@ const SfxPoolItem& SfxItemPool::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich SfxPoolItemArrayBase_Impl::iterator ppFree; bool ppFreeIsSet = false; + + // Is this a 'poolable' item - ie. should we re-use and return + // the same underlying item for equivalent (==) SfxPoolItems ? if ( IsItemFlag_Impl( nIndex, SFX_ITEM_POOLABLE ) ) { // if is already in a pool, then it is worth checking if it is in this one. @@ -751,7 +754,7 @@ const SfxPoolItem& SfxItemPool::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich } else { - // look for a freed place + // Unconditionally insert; check for a recently freed place if (pItemArr->maFree.size() > 0) { SfxPoolItemArrayBase_Impl::iterator itr = pItemArr->begin(); @@ -765,7 +768,7 @@ const SfxPoolItem& SfxItemPool::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich } } - // nicht vorhanden, also im PtrArray eintragen + // 3. not found, so clone to insert into the pointer array. SfxPoolItem* pNewItem = rItem.Clone(pImp->mpMaster); pNewItem->SetWhich(nWhich); #ifdef DBG_UTIL @@ -782,6 +785,7 @@ const SfxPoolItem& SfxItemPool::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich #endif AddRef( *pNewItem, pImp->nInitRefCount ); + // 4. finally insert into the pointer array assert( pItemArr->maHash.find(pNewItem) == pItemArr->maHash.end() ); if ( !ppFreeIsSet ) { -- cgit