Kaydet (Commit) 0c5d286c authored tarafından Noel Grandin's avatar Noel Grandin

rename some types in SfxPoolItemArray_Impl

to make their purpose clearer

Change-Id: I05597f5e69d2e471f08fec545467923378dded74
üst 4c1926f3
...@@ -72,13 +72,13 @@ typedef std::deque< SfxPoolVersion_ImplPtr > SfxPoolVersionArr_Impl; ...@@ -72,13 +72,13 @@ typedef std::deque< SfxPoolVersion_ImplPtr > SfxPoolVersionArr_Impl;
struct SfxPoolItemArray_Impl: public SfxPoolItemArrayBase_Impl struct SfxPoolItemArray_Impl: public SfxPoolItemArrayBase_Impl
{ {
typedef std::vector<sal_uInt32> FreeList; typedef std::vector<sal_uInt32> FreeList;
typedef std::unordered_map<SfxPoolItem*,sal_uInt32> Hash; typedef std::unordered_map<SfxPoolItem*,sal_uInt32> PoolItemPtrToIndexMap;
public: public:
/// Track list of indices into our array that contain an empty slot /// Track list of indices into our array that contain an empty slot
FreeList maFree; FreeList maFree;
/// Hash of SfxPoolItem pointer to index into our array that contains that slot /// Hash of SfxPoolItem pointer to index into our array that contains that slot
Hash maHash; PoolItemPtrToIndexMap maPtrToIndex;
SfxPoolItemArray_Impl () {} SfxPoolItemArray_Impl () {}
......
...@@ -688,11 +688,11 @@ const SfxPoolItem& SfxItemPool::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich ...@@ -688,11 +688,11 @@ const SfxPoolItem& SfxItemPool::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich
// if is already in a pool, then it is worth checking if it is in this one. // if is already in a pool, then it is worth checking if it is in this one.
if ( IsPooledItem(&rItem) ) if ( IsPooledItem(&rItem) )
{ {
SfxPoolItemArray_Impl::Hash::const_iterator it; SfxPoolItemArray_Impl::PoolItemPtrToIndexMap::const_iterator it;
it = pItemArr->maHash.find(const_cast<SfxPoolItem *>(&rItem)); it = pItemArr->maPtrToIndex.find(const_cast<SfxPoolItem *>(&rItem));
// 1. search for an identical pointer in the pool // 1. search for an identical pointer in the pool
if (it != pItemArr->maHash.end()) if (it != pItemArr->maPtrToIndex.end())
{ {
AddRef(rItem); AddRef(rItem);
return rItem; return rItem;
...@@ -755,17 +755,17 @@ const SfxPoolItem& SfxItemPool::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich ...@@ -755,17 +755,17 @@ const SfxPoolItem& SfxItemPool::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich
AddRef( *pNewItem, pImp->nInitRefCount ); AddRef( *pNewItem, pImp->nInitRefCount );
// 4. finally insert into the pointer array // 4. finally insert into the pointer array
assert( pItemArr->maHash.find(pNewItem) == pItemArr->maHash.end() ); assert( pItemArr->maPtrToIndex.find(pNewItem) == pItemArr->maPtrToIndex.end() );
if ( !ppFreeIsSet ) if ( !ppFreeIsSet )
{ {
sal_uInt32 nOffset = pItemArr->size(); sal_uInt32 nOffset = pItemArr->size();
pItemArr->maHash.insert(std::make_pair(pNewItem, nOffset)); pItemArr->maPtrToIndex.insert(std::make_pair(pNewItem, nOffset));
pItemArr->push_back( pNewItem ); pItemArr->push_back( pNewItem );
} }
else else
{ {
sal_uInt32 nOffset = std::distance(pItemArr->begin(), ppFree); sal_uInt32 nOffset = std::distance(pItemArr->begin(), ppFree);
pItemArr->maHash.insert(std::make_pair(pNewItem, nOffset)); pItemArr->maPtrToIndex.insert(std::make_pair(pNewItem, nOffset));
assert(*ppFree == NULL); assert(*ppFree == NULL);
*ppFree = pNewItem; *ppFree = pNewItem;
} }
...@@ -776,7 +776,7 @@ const SfxPoolItem& SfxItemPool::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich ...@@ -776,7 +776,7 @@ const SfxPoolItem& SfxItemPool::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich
void SfxPoolItemArray_Impl::ReHash() void SfxPoolItemArray_Impl::ReHash()
{ {
maFree.clear(); maFree.clear();
maHash.clear(); maPtrToIndex.clear();
for (size_t nIdx = 0; nIdx < size(); ++nIdx) for (size_t nIdx = 0; nIdx < size(); ++nIdx)
{ {
...@@ -785,8 +785,8 @@ void SfxPoolItemArray_Impl::ReHash() ...@@ -785,8 +785,8 @@ void SfxPoolItemArray_Impl::ReHash()
maFree.push_back(nIdx); maFree.push_back(nIdx);
else else
{ {
maHash.insert(std::make_pair(pItem,nIdx)); maPtrToIndex.insert(std::make_pair(pItem,nIdx));
assert(maHash.find(pItem) != maHash.end()); assert(maPtrToIndex.find(pItem) != maPtrToIndex.end());
} }
} }
} }
...@@ -835,9 +835,9 @@ void SfxItemPool::Remove( const SfxPoolItem& rItem ) ...@@ -835,9 +835,9 @@ void SfxItemPool::Remove( const SfxPoolItem& rItem )
SfxPoolItemArray_Impl* pItemArr = pImp->maPoolItems[nIndex]; SfxPoolItemArray_Impl* pItemArr = pImp->maPoolItems[nIndex];
SFX_ASSERT( pItemArr, rItem.Which(), "removing Item not in Pool" ); SFX_ASSERT( pItemArr, rItem.Which(), "removing Item not in Pool" );
SfxPoolItemArray_Impl::Hash::iterator it; SfxPoolItemArray_Impl::PoolItemPtrToIndexMap::iterator it;
it = pItemArr->maHash.find(const_cast<SfxPoolItem *>(&rItem)); it = pItemArr->maPtrToIndex.find(const_cast<SfxPoolItem *>(&rItem));
if (it != pItemArr->maHash.end()) if (it != pItemArr->maPtrToIndex.end())
{ {
sal_uInt32 nIdx = it->second; sal_uInt32 nIdx = it->second;
assert(nIdx < pItemArr->size()); assert(nIdx < pItemArr->size());
...@@ -858,7 +858,7 @@ void SfxItemPool::Remove( const SfxPoolItem& rItem ) ...@@ -858,7 +858,7 @@ void SfxItemPool::Remove( const SfxPoolItem& rItem )
DELETEZ(p); DELETEZ(p);
// remove ourselves from the hash // remove ourselves from the hash
pItemArr->maHash.erase(it); pItemArr->maPtrToIndex.erase(it);
// record that this slot is free // record that this slot is free
pItemArr->maFree.push_back( nIdx ); pItemArr->maFree.push_back( nIdx );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment