This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch tymux-10-quiet-head
in repository terminology.
View the commit online.
commit 2d0525d46eff325a1210c5412c56736cabad6aac
Author: Boris Faure <[email protected]>
AuthorDate: Fri Nov 6 22:17:58 2026 +0000
termpty: merge DECFRA's kept colours through a bit mask
Under default colours, DECFRA keeps each cell's colours: the cell was
rebuilt from eight colour bitfields copied one by one, and under set
colours it was stored with the same stalling struct assignment as the
other fills. A full screen DECFRA took 14 us.
The kept colours are now merged into the new attributes as 32-bit
words through a mask of the colour bits, a set-colour fill copies its
first cell over the rest, and the link and block bookkeeping is skipped
when neither was ever created, as in the other fills.
tybench, release build, best of 10 iterations, three interleaved runs,
MB/s before -> after:
fill (corpus) 39.5 -> 126.1
DECFRA only 1.16 -> 9.3
plain-ascii, rep, scroll, sgr, unicode, DECALN: unchanged within
the noise
---
src/bin/termpty.c | 73 ++++++++++++++++++++++++++++++++-----------------------
1 file changed, 43 insertions(+), 30 deletions(-)
diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index 32aae5bc..3a5c6e54 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -1800,56 +1800,69 @@ termpty_cells_set_content(Termpty *ty, Termcell *cells,
}
}
+_Static_assert(sizeof(Termatt) % sizeof(uint32_t) == 0,
+ "Termatt is merged as 32-bit words");
+
void
termpty_cells_att_fill_preserve_colors(Termpty *ty, Termcell *cells,
Eina_Unicode codepoint, int count)
{
- int i;
+ enum { ATT_WORDS = sizeof(Termatt) / sizeof(uint32_t) };
Termatt att = ty->termstate.att;
- Termcell local = { .codepoint = codepoint, .att = att };
+ Termatt colors;
+ uint32_t att_words[ATT_WORDS], color_words[ATT_WORDS];
+ int i, k;
- if (EINA_UNLIKELY(local.att.link_id))
- term_link_refcount_inc(ty, local.att.link_id, count);
+ if (count <= 0) return;
- /* The SGR state is the same for the whole fill, so "are its colours
- * default" is answered once and each case becomes a plain loop rather
- * than a per-cell test. */
- if (att.fg != 0 || att.fgrgb != 0 || att.bg != 0 || att.bgrgb != 0)
+ if (EINA_UNLIKELY(att.link_id))
+ term_link_refcount_inc(ty, att.link_id, count);
+
+ /* Same invariant as TERMPTY_CELL_COPY()'s fast path. */
+ if (EINA_UNLIKELY((ty->hl.size != 0) || (ty->block.blocks != NULL)))
{
for (i = 0; i < count; i++)
{
HANDLE_BLOCK_CODEPOINT_OVERWRITE(ty, cells[i].codepoint, codepoint);
if (EINA_UNLIKELY(cells[i].att.link_id))
term_link_refcount_dec(ty, cells[i].att.link_id, 1);
-
- cells[i] = local;
}
+ }
+
+ /* Colours set by SGR replace the cells' own. */
+ if (att.fg != 0 || att.fgrgb != 0 || att.bg != 0 || att.bgrgb != 0)
+ {
+ cells[0].codepoint = codepoint;
+ cells[0].att = att;
+ termpty_cells_replicate(cells, count);
return;
}
+ /* Default colours: each cell keeps its own, merged in by a mask of the
+ * colour bits rather than field by field. */
+ memset(&colors, 0, sizeof(colors));
+ colors.fg = 0xffffff;
+ colors.fgrgb = 1;
+ colors.fg256 = 1;
+ colors.fgintense = 1;
+ colors.bg = 0xffffff;
+ colors.bgrgb = 1;
+ colors.bg256 = 1;
+ colors.bgintense = 1;
+ memcpy(color_words, &colors, sizeof(colors));
+ memcpy(att_words, &att, sizeof(att));
+ for (k = 0; k < ATT_WORDS; k++)
+ att_words[k] &= ~color_words[k];
+
for (i = 0; i < count; i++)
{
- Termatt old = cells[i].att;
- Termcell c;
+ uint32_t words[ATT_WORDS];
- HANDLE_BLOCK_CODEPOINT_OVERWRITE(ty, cells[i].codepoint, codepoint);
- if (EINA_UNLIKELY(cells[i].att.link_id))
- term_link_refcount_dec(ty, cells[i].att.link_id, 1);
-
- /* The cell keeps its colours. Built once and stored once, for the
- * same reason as in the ASCII run path. */
- c.codepoint = codepoint;
- c.att = att;
- c.att.fg = old.fg;
- c.att.fgrgb = old.fgrgb;
- c.att.fg256 = old.fg256;
- c.att.fgintense = old.fgintense;
-
- c.att.bg = old.bg;
- c.att.bgrgb = old.bgrgb;
- c.att.bg256 = old.bg256;
- c.att.bgintense = old.bgintense;
- cells[i] = c;
+ memcpy(words, &cells[i].att, sizeof(words));
+ for (k = 0; k < ATT_WORDS; k++)
+ words[k] = att_words[k] | (words[k] & color_words[k]);
+ cells[i].codepoint = codepoint;
+ memcpy(&cells[i].att, words, sizeof(words));
}
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.