Commits

Bjoern Michaelsen  committed 3e75e93

new_itemsets: not using optimizations in EqualForPoolcache for now, as prereques. do not seem to be met

  • Participants
  • Parent commits d636801

Comments (0)

Files changed (3)

File sc/source/core/data/patattr.cxx

 {
     // #i62090# Use quick comparison between ScPatternAttr's ItemSets
 
-    return ( GetItemSet().EqualWithSameRangeAllPooled(static_cast<const ScPatternAttr&>(rCmp).GetItemSet()) &&
+    return ( GetItemSet().EqualForPoolcache(static_cast<const ScPatternAttr&>(rCmp).GetItemSet()) &&
              StrCmp( GetStyleName(), static_cast<const ScPatternAttr&>(rCmp).GetStyleName() ) );
 }
 

File svl/inc/svl/itemset.hxx

 
         // #i62090# performance hack under the assumption of sets
         // with equal which ranges and all items pooled in the same pool
-        SAL_FLATFUNCTION SAL_HOTFUNCTION SAL_NOTHROW bool EqualWithSameRangeAllPooled(const SfxItemSet& rCmp) const
-        {
-            //OSL_PRECOND(m_pParent == rCmp.m_pParent, "<itemset.hxx:SfxItemSet.EqualWithSameRangeAllPooled(..)>"
-            //    " - comparing itemsets with different parents.");
-            OSL_PRECOND(m_pPool == rCmp.m_pPool, "<itemset.SfxItemSet.EqualWithSameRangeAllPooled(..)>"
-                " - comparing itemsets from different pools.");
-
-            OSL_PRECOND(m_vWhichRanges == rCmp.m_vWhichRanges, "<itemset.hxx:SfxItemSet.EqualWithSameRangeAllPooled(..)>"
-                " - comparing itemsets with different which ranges.");
-            const bool isEqual = (m_pParent == rCmp.m_pParent) &&
-                (m_pItems->size() == rCmp.m_pItems->size()) &&
-                    (m_pItems->empty() ||
-                    memcmp(&((*m_pItems)[0]), &((*rCmp.m_pItems)[0]), m_pItems->size() * sizeof(sfx::item::ItemEntry)));
-            OSL_POSTCOND( (*this == rCmp) == isEqual, "<itemset.hxx:SfxItemSet.EqualWithSameRangeAllPooled(..)>"
-                " - result differs from operator==.");
-            return isEqual;
-        };
+        // ignoring different parents
+        SAL_FLATFUNCTION SAL_HOTFUNCTION SAL_NOTHROW bool EqualForPoolcache(const SfxItemSet& rCmp) const;
 
 #if OSL_DEBUG_LEVEL > 1
     private:

File svl/source/items/itemset.cxx

             OSL_ENSURE(lcl_InRange(rWhichRanges, pItemEntry->GetWhich()), "<itemset.cxx:lcl_ValidateItemVector>"
             " - itemset confused: which out of ranges.");
             if(!lcl_InRange(rWhichRanges, pItemEntry->GetWhich()))
-				*((int*)NULL) = 0;
+                *((int*)NULL) = 0;
             OSL_ENSURE(IsInvalidItem(pItemEntry->GetItem()) || pItemEntry->GetItem()->Which() || pItemEntry->GetItem()->IsA(TYPE(SfxVoidItem)),
                 "<itemset.cxx:lcl_ValidateItemVector> - itemset confused: item has to be invalid, have a WhichId or be a SfxVoidItem.");
         }
                 || !rItemEntry2.GetItem() || IsInvalidItem(rItemEntry2.GetItem()))
                 return false;
             // ... so that we dont dereference them here.
-            if(m_pPool->IsItemFlag(*rItemEntry1.GetItem(), SFX_ITEM_POOLABLE)
+            if(m_pPool->IsItemFlag(rItemEntry1.GetWhich(), SFX_ITEM_POOLABLE)
                 || *(rItemEntry1.GetItem()) != *(rItemEntry2.GetItem()))
                 return false;
         }
             : new SfxItemSet(*m_pPool, &m_vWhichRanges[0]);
 }
 
+bool SfxItemSet::EqualForPoolcache(const SfxItemSet& rCmp) const
+{
+    OSL_PRECOND(m_pPool == rCmp.m_pPool, "<SfxItemSet::EqualForPoolcache(..)>"
+        " - comparing itemsets from different pools.");
+
+    OSL_PRECOND(m_vWhichRanges == rCmp.m_vWhichRanges, "<SfxItemSet::EqualForPoolcache(..)>"
+        " - comparing itemsets with different which ranges.");
+#if OSL_DEBUG_LEVEL > 0
+    SfxWhichIter aIter(*this);
+    for(sal_uInt16 nWhich = aIter.FirstWhich(); nWhich; nWhich = aIter.NextWhich())
+        OSL_PRECOND(m_pPool->IsItemFlag(nWhich, SFX_ITEM_POOLABLE),  "<SfxItemSet::EqualForPoolcache(..)>"
+            " - comparing sets with non poolable items");
+#endif
+    // this is how it should work, however since this function is used to compare sets not meeting the
+    // preconditions, this is disabled for now
+    // return *m_pItems == *rCmp.m_pItems;
+    return *this == rCmp;
+}
+
 #if OSL_DEBUG_LEVEL > 1
 #include <rtl/ustring.hxx>
 #include <rtl/string.hxx>
     lcl_appendPtr(sBuffer,i_pSet);
     sBuffer.appendAscii("\n");
     sBuffer.appendAscii("parent: ((struct SfxItemSet*)");
-    lcl_appendPtr(sBuffer,i_pSet);
+    lcl_appendPtr(sBuffer,i_pSet->m_pParent);
+    sBuffer.appendAscii(")\n");
+    sBuffer.appendAscii("pool: ((struct SfxItemPool*)");
+    lcl_appendPtr(sBuffer,i_pSet->m_pPool);
     sBuffer.appendAscii(")\n");
     sBuffer.appendAscii("WhichRanges: ");
     for(vector<sal_uInt16>::const_iterator pRange = i_pSet->m_vWhichRanges.begin();