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,
iterator start)
{
if (where < start->begin())
if (start == end() or where < start->begin())
return end();
return std::upper_bound(start, end(), where,
[](const BufferIterator& where, const DisplayAtom& atom)
{ return where < atom.end(); });
while (start != end())
{
if (start->end() > where)
break;
++start;
}
return start;
}
DisplayBuffer::iterator DisplayBuffer::split(iterator atom, const BufferIterator& pos)