[Libreoffice-commits] core.git: svl/source
Noel Grandin
noel at peralex.com
Mon Oct 31 09:49:24 UTC 2016
svl/source/items/itemset.cxx | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
New commits:
commit b70f10e0811bb344db91332edc16410a66f4c36e
Author: Noel Grandin <noel at peralex.com>
Date: Mon Oct 31 11:38:38 2016 +0200
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 at 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 at collabora.com>
Tested-by: Tor Lillqvist <tml at collabora.com>
diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx
index 745d96a..9a67f73 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
More information about the Libreoffice-commits
mailing list