diff options
| author | Maxime Coste <mawww@kakoune.org> | 2023-06-12 14:38:31 +1000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2023-06-12 16:26:22 +1000 |
| commit | af66a95ef882447ca7bdc2149a8dfde50035301e (patch) | |
| tree | eae2a373b6102aca954b5fb0a8b3d7d2b2a223f1 /src/display_buffer.cc | |
| parent | 5a867ebdd1dac274da185f4a4630b8480181cb9b (diff) | |
Trim display lines before the colorize pass
Colorizing long lines can be costly, remove all the invisible atoms
earlier. Also optimize ForwardHighlighterApplier further by trimming
empty lines.
Diffstat (limited to 'src/display_buffer.cc')
| -rw-r--r-- | src/display_buffer.cc | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/display_buffer.cc b/src/display_buffer.cc index 92837c6a..26c58754 100644 --- a/src/display_buffer.cc +++ b/src/display_buffer.cc @@ -264,18 +264,22 @@ bool DisplayLine::trim_from(ColumnCount first_col, ColumnCount front, ColumnCoun } auto front_it = it; - Face last_face{}; + Optional<DisplayAtom> padding; while (front > 0 and it != end()) { front -= it->trim_begin(front); kak_assert(it->empty() or front <= 0); - last_face = it->face; + if (front < 0) + padding.emplace(it->has_buffer_range() + ? DisplayAtom{it->buffer(), {it->begin(), it->begin()}, String{' ', -front}, it->face} + : DisplayAtom{String{' ', -front}, it->face}); + if (it->empty()) ++it; } it = m_atoms.erase(front_it, it); - if (front < 0) - it = m_atoms.insert(it, DisplayAtom{String{' ', -front}, last_face}); + if (padding) + it = m_atoms.insert(it, std::move(*padding)); it = begin(); for (; it != end() and col_count > 0; ++it) |
