diff options
| author | Maxime Coste <mawww@kakoune.org> | 2023-02-03 11:31:13 +1100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2023-02-03 11:31:13 +1100 |
| commit | eb0e9831330d3b1e1d3ddb2bc789000706e6e445 (patch) | |
| tree | 661022a3d9c8ecc51540778e7ab024677ee1169e /src/display_buffer.cc | |
| parent | 9257beac88e45df4752952597773dd51bebceca4 (diff) | |
Fix DisplayLine::trim_front quadratic behaviour
Erasing fully trimmed display atoms one by one means we have to
shift all the remaining ones every time. This is wasteful and we
can just erase all the fully trimmed atom in one go.
Fixes #4797
Diffstat (limited to 'src/display_buffer.cc')
| -rw-r--r-- | src/display_buffer.cc | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/display_buffer.cc b/src/display_buffer.cc index 02007d8f..0fd180b6 100644 --- a/src/display_buffer.cc +++ b/src/display_buffer.cc @@ -252,12 +252,15 @@ bool DisplayLine::trim_from(ColumnCount first_col, ColumnCount front, ColumnCoun } } + auto front_it = it; while (front > 0 and it != end()) { front -= it->trim_begin(front); + kak_assert(it->empty() or front == 0); if (it->empty()) - it = m_atoms.erase(it); + ++it; } + m_atoms.erase(front_it, it); it = begin(); for (; it != end() and col_count > 0; ++it) |
