From af66a95ef882447ca7bdc2149a8dfde50035301e Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 12 Jun 2023 14:38:31 +1000 Subject: 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. --- src/display_buffer.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/display_buffer.cc') 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 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) -- cgit v1.2.3