From f259e20c53fc61342a39adceb7de9e8f08d8431d Mon Sep 17 00:00:00 2001 From: Leonard Hecker Date: Wed, 13 Aug 2025 18:10:18 +0200 Subject: [PATCH] Fix a output marks performance regression (#19242) An alternative approach for #18291. Improves perf by ~7%. (cherry picked from commit 6b19d218457697794faaf4794451ba5f8ebff252) Service-Card-Id: PVTI_lADOAF3p4s4AmhmQzgdm49Y Service-Version: 1.22 --- src/buffer/out/Row.cpp | 4 ++-- src/buffer/out/Row.hpp | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/buffer/out/Row.cpp b/src/buffer/out/Row.cpp index a58a58622b..34dffed834 100644 --- a/src/buffer/out/Row.cpp +++ b/src/buffer/out/Row.cpp @@ -937,12 +937,12 @@ void ROW::_resizeChars(uint16_t colEndDirty, uint16_t chBegDirty, size_t chEndDi } } -til::small_rle& ROW::Attributes() noexcept +RowAttributes& ROW::Attributes() noexcept { return _attr; } -const til::small_rle& ROW::Attributes() const noexcept +const RowAttributes& ROW::Attributes() const noexcept { return _attr; } diff --git a/src/buffer/out/Row.hpp b/src/buffer/out/Row.hpp index d2c19036ba..4d6f45f8d9 100644 --- a/src/buffer/out/Row.hpp +++ b/src/buffer/out/Row.hpp @@ -14,6 +14,11 @@ class ROW; class TextBuffer; +// Because MarkKind::Output gets set only on the actually written text, +// most rows will end up having at least 2 runs: The start of the line +// with MarkKind::Output and the rest of the line with MarkKind::None. +using RowAttributes = til::small_rle; + enum class DelimiterClass { ControlChar, @@ -148,8 +153,8 @@ public: void ReplaceText(RowWriteState& state); void CopyTextFrom(RowCopyTextFromState& state); - til::small_rle& Attributes() noexcept; - const til::small_rle& Attributes() const noexcept; + RowAttributes& Attributes() noexcept; + const RowAttributes& Attributes() const noexcept; TextAttribute GetAttrByColumn(til::CoordType column) const; std::vector GetHyperlinks() const; ImageSlice* SetImageSlice(ImageSlice::Pointer imageSlice) noexcept; @@ -297,7 +302,7 @@ private: std::span _charOffsets; // _attr is a run-length-encoded vector of TextAttribute with a decompressed // length equal to _columnCount (= 1 TextAttribute per column). - til::small_rle _attr; + RowAttributes _attr; // The width of the row in visual columns. uint16_t _columnCount = 0; // Stores double-width/height (DECSWL/DECDWL/DECDHL) attributes.