diff options
author | Noel Grandin <noel@peralex.com> | 2016-10-31 11:38:38 +0200 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2016-10-31 09:49:00 +0000 |
commit | b70f10e0811bb344db91332edc16410a66f4c36e (patch) | |
tree | 34eec3064f8263016e61a13e7b804b90dff2fc86 /svl | |
parent | 978c6e7a8fae309d4b3f3f1e422ca9d91a427469 (diff) |
fix use of is_sorted_until
fix for
"comparison doesn't meet irreflexive requirements, assert(!(a < a))"
as a consequence of
author Jochen Nitschke <j.nitschke+logerrit@ok.de>
commit e75561bd19faa332c077ec249a397d056fae63f2
bin SfxUShortRanges, inline and rewrite only usage
seems that std::is_sorted_until has stronger requirements than we
actually want here, so open-code a similar algorithm
Change-Id: I126584d9146137b9ac699dad85fd9691490dc30d
Reviewed-on: https://gerrit.libreoffice.org/30435
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
Diffstat (limited to 'svl')
-rw-r--r-- | svl/source/items/itemset.cxx | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx index 745d96a86c67..9a67f73f52d8 100644 --- a/svl/source/items/itemset.cxx +++ b/svl/source/items/itemset.cxx @@ -625,14 +625,29 @@ 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;}; - std::vector<std::pair<sal_uInt16, sal_uInt16> >::iterator it = aRangesTable.begin(); - // check neighbouring ranges, find first range which overlaps or adjoins a previous range - while ((it = std::is_sorted_until(it, aRangesTable.end(), needMerge)) != aRangesTable.end()) + for (;;) { - --it; // merge with previous range + // 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 (;;) + { + itNext = std::next(it); + if (itNext == aRangesTable.end()) + break; + if (needMerge(*it, *itNext)) + break; + ++it; + } + 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[0].second, it[1].second); - aRangesTable.erase(std::next(it)); + it->second = std::max(it->second, itNext->second); + aRangesTable.erase(itNext); } // construct range array |