Binary search for first range to change

This commit is contained in:
Jason Felice 2021-03-08 15:26:38 -05:00
parent da80a8cf6a
commit c9be6730f6

View File

@ -53,8 +53,10 @@ void update_forward(ConstArrayView<Buffer::Change> changes, RangeContainer& rang
changes_tracker.update(*it++);
};
for (auto& range : ranges)
update_range(changes_tracker, range, advance_while_relevant);
auto range_it = std::lower_bound(ranges.begin(), ranges.end(), changes.front(),
[](auto& range, const Buffer::Change& change) { return get_last(range) < change.begin; });
for (auto end = ranges.end(); range_it != end; ++range_it)
update_range(changes_tracker, *range_it, advance_while_relevant);
}
template<typename RangeContainer>