[Libreoffice-commits] core.git: svl/source

Jochen Nitschke j.nitschke+logerrit at ok.de
Sun Sep 4 15:24:13 UTC 2016


 svl/source/items/itempool.cxx |   13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

New commits:
commit 9684040d81ff2e9c5847d2d9c7fbec505775cbba
Author: Jochen Nitschke <j.nitschke+logerrit at ok.de>
Date:   Sun Sep 4 16:22:18 2016 +0200

    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 at ok.de>
    Tested-by: Jochen Nitschke <j.nitschke+logerrit at ok.de>

diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx
index 5d1b6a7..d67c56d 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


More information about the Libreoffice-commits mailing list