1. mst
  2. ooo340

Commits

Bjoern Michaelsen  committed 5c61a85

itemsets: using stack allocated vectors for performance, fixing bug dereferencing invalid item

  • Participants
  • Parent commits 0f5dd0a
  • Branches new_itemsets

Comments (0)

Files changed (1)

File svtools/source/items1/itemset.cxx

View file
  • Ignore whitespace
         ++pItemEntry)
     {
         SfxItemPool* pPool = NULL;
-        if(!m_pPool->IsItemFlag(*pItemEntry->GetItem(), SFX_ITEM_POOLABLE))
+        const SfxPoolItem* pItem = pItemEntry->GetItem();
+        if(!IsInvalidItem(pItem) && !m_pPool->IsItemFlag(*pItem, SFX_ITEM_POOLABLE))
             pPool = m_pPool;
         pItemEntry->SetItem(const_cast<SfxPoolItem*>(pItemEntry->GetItem()), pPool);
     }
         return false;
     }
     bool bAllCandidatesInRange = false;
-    auto_ptr<vector<ItemEntry> > pSourceItems;
+    vector<ItemEntry> vSourceItems, vOldSoureItems;
+    vector<ItemEntry>* pSourceItems = &vSourceItems;
+    vector<ItemEntry>* pOldSourceItems = &vOldSoureItems;
     vector<ItemEntry>::iterator pCandidatesBegin;
     vector<ItemEntry>::iterator pCandidatesEnd;
     if(bDeep && rSet.m_pParent)
     {
         bAllCandidatesInRange = true;
-        auto_ptr<vector<sal_uInt16> > pLegalWhichRange(new vector<sal_uInt16>());
-        auto_ptr<vector<sal_uInt16> > pOldLegalWhichRange(new vector<sal_uInt16>());
-        auto_ptr<vector<ItemEntry> > pOldSourceItems(new vector<ItemEntry>());
-        pSourceItems.reset(new vector<ItemEntry>());
+        vector<sal_uInt16> vLegalWhichRange, vOldLegalWhichRange;
+        vector<sal_uInt16>* pLegalWhichRange = &vLegalWhichRange;
+        vector<sal_uInt16>* pOldLegalWhichRange = &vOldLegalWhichRange;
         pSourceItems->reserve(128);
         pOldSourceItems->reserve(128);
         pLegalWhichRange->reserve(32);
             pCurrentSet = pCurrentSet->m_pParent)
         {
             swap(pLegalWhichRange, pOldLegalWhichRange);
-            lcl_IntersectWhichRanges(pOldLegalWhichRange.get(), &pCurrentSet->m_vWhichRanges, pLegalWhichRange.get());
+            lcl_IntersectWhichRanges(pOldLegalWhichRange, &pCurrentSet->m_vWhichRanges, pLegalWhichRange);
             if(pLegalWhichRange->size() < 3)
                 break;
             ItemVector::iterator pLastRangeStart, pLastRangeEnd;