diff options
author | Jochen Nitschke <j.nitschke+logerrit@ok.de> | 2016-09-04 16:22:18 +0200 |
---|---|---|
committer | Jochen Nitschke <j.nitschke+logerrit@ok.de> | 2016-09-04 15:23:46 +0000 |
commit | 9684040d81ff2e9c5847d2d9c7fbec505775cbba (patch) | |
tree | b35d395b8eab09af467781063efec2cff1d89c4d /svl | |
parent | c36489be617be3e8ca25612d29afb221bc7ae6c1 (diff) |
get index only when needed
GetIndex_Impl can't be USHRT_MAX
for nWhich > SFX_MAX_WHICH bSID is true and GetIndex_Impl
returns nWhich - pImpl->mnStart
Change-Id: I392e544d65196b7af143ee1864f9065e92b717d1
Reviewed-on: https://gerrit.libreoffice.org/28665
Reviewed-by: Jochen Nitschke <j.nitschke+logerrit@ok.de>
Tested-by: Jochen Nitschke <j.nitschke+logerrit@ok.de>
Diffstat (limited to 'svl')
-rw-r--r-- | svl/source/items/itempool.cxx | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx index 5d1b6a71c478..d67c56dd4fb7 100644 --- a/svl/source/items/itempool.cxx +++ b/svl/source/items/itempool.cxx @@ -630,10 +630,9 @@ const SfxPoolItem& SfxItemPool::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich } // SID ? - sal_uInt16 nIndex = bSID ? USHRT_MAX : GetIndex_Impl(nWhich); - if ( USHRT_MAX == nIndex ) + if (bSID) { - assert((USHRT_MAX != nIndex || rItem.Which() != nWhich || + assert((rItem.Which() != nWhich || !IsDefaultItem(&rItem) || rItem.GetKind() == SFX_ITEMS_DELETEONIDLE) && "a non Pool Item is Default?!"); SfxPoolItem *pPoolItem = rItem.Clone(pImpl->mpMaster); @@ -645,6 +644,7 @@ const SfxPoolItem& SfxItemPool::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich assert(!pImpl->ppStaticDefaults || typeid(rItem) == typeid(GetDefaultItem(nWhich))); + const sal_uInt16 nIndex = GetIndex_Impl(nWhich); SfxPoolItemArray_Impl* pItemArr = pImpl->maPoolItems[nIndex]; if (!pItemArr) { @@ -779,11 +779,9 @@ void SfxItemPool::Remove( const SfxPoolItem& rItem ) } // SID ? - sal_uInt16 nIndex = bSID ? USHRT_MAX : GetIndex_Impl(nWhich); if ( bSID ) { - assert((USHRT_MAX != nIndex || !IsDefaultItem(&rItem)) && - "a non Pool Item is Default?!"); + assert(!IsDefaultItem(&rItem) && "a non Pool Item is Default?!"); if ( 0 == ReleaseRef(rItem) ) { SfxPoolItem *pItem = &(SfxPoolItem &)rItem; @@ -794,9 +792,10 @@ void SfxItemPool::Remove( const SfxPoolItem& rItem ) assert(rItem.GetRefCount() && "RefCount == 0, Remove impossible"); + const sal_uInt16 nIndex = GetIndex_Impl(nWhich); // Static Defaults are just there if ( IsStaticDefaultItem(&rItem) && - &rItem == *( pImpl->ppStaticDefaults + GetIndex_Impl(nWhich) ) ) + &rItem == pImpl->ppStaticDefaults[nIndex]) return; // Find Item in own Pool |