summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--svl/source/items/itemset.cxx29
1 files changed, 10 insertions, 19 deletions
diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx
index 9a67f73f52d8..6c00f5c009c8 100644
--- a/svl/source/items/itemset.cxx
+++ b/svl/source/items/itemset.cxx
@@ -625,29 +625,20 @@ void SfxItemSet::MergeRange( sal_uInt16 nFrom, sal_uInt16 nTo )
auto needMerge = [](std::pair<sal_uInt16, sal_uInt16> lhs, std::pair<sal_uInt16, sal_uInt16> rhs)
{return (lhs.first-1) <= rhs.second && (rhs.first-1) <= lhs.second;};
- for (;;)
+ std::vector<std::pair<sal_uInt16, sal_uInt16> >::iterator it = aRangesTable.begin();
+ std::vector<std::pair<sal_uInt16, sal_uInt16> >::iterator itNext;
+ // we got at least one range
+ while ((itNext = std::next(it)) != aRangesTable.end())
{
// check neighbouring ranges, find first range which overlaps or adjoins a previous range
- std::vector<std::pair<sal_uInt16, sal_uInt16> >::iterator it = aRangesTable.begin();
- if (it == aRangesTable.end())
- break;
- std::vector<std::pair<sal_uInt16, sal_uInt16> >::iterator itNext;
- for (;;)
+ if (needMerge(*it, *itNext))
{
- itNext = std::next(it);
- if (itNext == aRangesTable.end())
- break;
- if (needMerge(*it, *itNext))
- break;
- ++it;
+ // lower bounds are sorted, implies: it->first = min(it[0].first, it[1].first)
+ it->second = std::max(it->second, itNext->second);
+ aRangesTable.erase(itNext);
}
- if (itNext == aRangesTable.end())
- break;
-
- // merge with next range
- // lower bounds are sorted, implies: it->first = min(it[0].first, it[1].first)
- it->second = std::max(it->second, itNext->second);
- aRangesTable.erase(itNext);
+ else
+ ++it;
}
// construct range array