Commits

Bjoern Michaelsen  committed 8e08444

itemsets: refactored to a static function in anonymous namespace for readability

  • Participants
  • Parent commits 34c636b
  • Branches new_itemsets

Comments (0)

Files changed (1)

File svtools/source/items1/itemset.cxx

         }
         o_rResult.push_back(0);
     }
+
+    static void lcl_FindRange(
+        vector<sal_uInt16>::const_iterator pRange,
+        const ItemVector::iterator pStartSearchRange, const ItemVector::iterator pEndSearchRange,
+        ItemVector::iterator& o_pStart, ItemVector::iterator& o_pEnd)
+    {
+        o_pStart = lower_bound(pStartSearchRange, pEndSearchRange, ItemEntry(*pRange));
+        o_pEnd = upper_bound(o_pStart, pEndSearchRange, ItemEntry(*(pRange+1)));
+    }
 }
 
 namespace sfx { namespace item {
             lcl_IntersectWhichRanges(vOldLegalWhichRange, pCurrentSet->m_vWhichRanges, vLegalWhichRange);
             if(vLegalWhichRange.size() < 3)
                 break;
-            ItemVector::iterator pLastRangeStart = lower_bound(
-                    pCurrentSet->m_pItems->begin(),
-                    pCurrentSet->m_pItems->end(),
-                    ItemEntry(vLegalWhichRange[0]));
-            ItemVector::iterator pLastRangeEnd = upper_bound(
-                    pLastRangeStart,
-                    pCurrentSet->m_pItems->end(),
-                    ItemEntry(vLegalWhichRange[1]));
+            ItemVector::iterator pLastRangeStart, pLastRangeEnd;
+            lcl_FindRange(
+                vLegalWhichRange.begin(),
+                pCurrentSet->m_pItems->begin(), pCurrentSet->m_pItems->end(),
+                pLastRangeStart, pLastRangeEnd);
             for(vector<sal_uInt16>::const_iterator pCurrentRange = vLegalWhichRange.begin()+2;
                 *pCurrentRange && pLastRangeEnd != pCurrentSet->m_pItems->end();
                 pCurrentRange += 2)
             {
-                ItemVector::iterator pStart = lower_bound(
-                    pLastRangeEnd,
-                    pCurrentSet->m_pItems->end(),
-                    ItemEntry(*pCurrentRange));
-                ItemVector::iterator pEnd = upper_bound(
-                    pStart,
-                    pCurrentSet->m_pItems->end(),
-                    ItemEntry(*(pCurrentRange+1)));
+                ItemVector::iterator pStart, pEnd;
+                lcl_FindRange(
+                    pCurrentRange,
+                    pLastRangeEnd, pCurrentSet->m_pItems->end(),
+                    pStart, pEnd);
                 if(pStart != pLastRangeEnd)
                 {
                     swap(pSourceItems, pOldSourceItems);