mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-25 04:24:48 +03:00
use std::upper_bound in DisplayBuffer::atom_containing to run in O(log n)
This commit is contained in:
parent
e4b872abd2
commit
af5c528f04
@ -1,6 +1,7 @@
|
|||||||
#include "display_buffer.hh"
|
#include "display_buffer.hh"
|
||||||
|
|
||||||
#include "assert.hh"
|
#include "assert.hh"
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
namespace Kakoune
|
namespace Kakoune
|
||||||
{
|
{
|
||||||
@ -92,12 +93,9 @@ 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)
|
||||||
{
|
{
|
||||||
for (iterator it = start; it != m_atoms.end(); ++it)
|
return std::upper_bound(start, end(), where,
|
||||||
{
|
[](const BufferIterator& where, const DisplayAtom& atom)
|
||||||
if (it->end() > where)
|
{ return where < atom.end(); });
|
||||||
return it->begin() <= where ? it : end();
|
|
||||||
}
|
|
||||||
return end();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DisplayBuffer::iterator DisplayBuffer::split(iterator atom, const BufferIterator& pos)
|
DisplayBuffer::iterator DisplayBuffer::split(iterator atom, const BufferIterator& pos)
|
||||||
|
Loading…
Reference in New Issue
Block a user