Use binary search in IndexSet::find()

This commit is contained in:
Thomas Goyne 2016-03-14 15:13:19 -07:00
parent f1f0327146
commit 1a8a56d10a
1 changed files with 2 additions and 5 deletions

View File

@ -54,11 +54,8 @@ IndexSet::iterator IndexSet::find(size_t index)
IndexSet::iterator IndexSet::find(size_t index, iterator it)
{
for (auto end = m_ranges.end(); it != end; ++it) {
if (it->second > index)
return it;
}
return m_ranges.end();
return std::lower_bound(it, m_ranges.end(), std::make_pair(size_t(0), index + 1),
[&](auto const& a, auto const& b) { return a.second < b.second; });
}
void IndexSet::add(size_t index)