make DisplayBuffer::atom_containing easier to understand

This commit is contained in:
Maxime Coste 2012-07-03 21:12:05 +02:00
parent d7e1cab116
commit d092afead9

View File

@ -110,12 +110,16 @@ DisplayBuffer::iterator DisplayBuffer::atom_containing(const BufferIterator& whe
DisplayBuffer::iterator DisplayBuffer::atom_containing(const BufferIterator& where, DisplayBuffer::iterator DisplayBuffer::atom_containing(const BufferIterator& where,
iterator start) iterator start)
{ {
if (where < start->begin()) if (start == end() or where < start->begin())
return end(); return end();
return std::upper_bound(start, end(), where, while (start != end())
[](const BufferIterator& where, const DisplayAtom& atom) {
{ return where < atom.end(); }); if (start->end() > where)
break;
++start;
}
return start;
} }
DisplayBuffer::iterator DisplayBuffer::split(iterator atom, const BufferIterator& pos) DisplayBuffer::iterator DisplayBuffer::split(iterator atom, const BufferIterator& pos)