From 9684040d81ff2e9c5847d2d9c7fbec505775cbba Mon Sep 17 00:00:00 2001 From: Jochen Nitschke Date: Sun, 4 Sep 2016 16:22:18 +0200 Subject: 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 Tested-by: Jochen Nitschke --- svl/source/items/itempool.cxx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'svl') 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 -- cgit