This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository terminology.

View the commit online.

commit 358124f7a92df5ad47d5966fcafc5365a2146e17
Author: Cedric BAIL <[email protected]>
AuthorDate: Mon Aug 3 13:50:33 2026 -0600

    termpty: skip the cell-copy bookkeeping when no links or blocks exist
    
    TERMPTY_CELL_COPY runs a per-cell loop before its memcpy, testing each cell
    for a media-block codepoint and adjusting link refcounts on both source and
    destination. Every row that scrolls, every insert and delete, and every row
    saved to the backlog pays for it.
    
    None of it can do anything unless this terminal has created a link or a
    block: link ids are the only thing that needs refcounting, and blocks are the
    only producer of codepoints with bit 31 set. hl.size only ever grows from
    zero and block.blocks is only ever assigned, so both tests are true only if
    the feature was never used -- and if it was, the full loop still runs.
    Checking once per copy instead of three times per cell covers all thirteen
    call sites.
    
    The refcount calls inside the macro also used a literal 'ty' rather than the
    Tpty it is handed. Every call site happens to name its pty 'ty', so it worked;
    rewriting the loop is the moment to stop relying on that.
    
    Callgrind: 24% fewer instructions on the scroll corpus, 21% on plain ASCII.
    
    Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
---
 src/bin/termpty.h | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/src/bin/termpty.h b/src/bin/termpty.h
index 423ce37d..74313ff1 100644
--- a/src/bin/termpty.h
+++ b/src/bin/termpty.h
@@ -406,19 +406,25 @@ do {                                                                         \
        termpty_handle_block_codepoint_overwrite_heavy(Tpty, OLDC, NEWC);     \
 } while (0)
 
+/* No cell can carry a link id or a bit-31 block codepoint unless one was ever
+ * created, so the bookkeeping loop is skippable. hl.size and block.blocks both
+ * only ever go from unset to set. */
 #define TERMPTY_CELL_COPY(Tpty, Tsrc, Tdst, N)                               \
 do {                                                                         \
-   int __i;                                                                  \
-                                                                             \
-   for (__i = 0; __i < N; __i++)                                             \
+   if (EINA_UNLIKELY(((Tpty)->hl.size != 0) || ((Tpty)->block.blocks)))      \
      {                                                                       \
-        HANDLE_BLOCK_CODEPOINT_OVERWRITE(Tpty,                               \
-                                         (Tdst)[__i].codepoint,              \
-                                         (Tsrc)[__i].codepoint);             \
-        if (EINA_UNLIKELY((Tdst)[__i].att.link_id))                          \
-          term_link_refcount_dec(ty, (Tdst)[__i].att.link_id, 1);            \
-        if (EINA_UNLIKELY((Tsrc)[__i].att.link_id))                          \
-          term_link_refcount_inc(ty, (Tsrc)[__i].att.link_id, 1);            \
+        int __i;                                                             \
+                                                                             \
+        for (__i = 0; __i < N; __i++)                                        \
+          {                                                                  \
+             HANDLE_BLOCK_CODEPOINT_OVERWRITE(Tpty,                          \
+                                              (Tdst)[__i].codepoint,         \
+                                              (Tsrc)[__i].codepoint);        \
+             if (EINA_UNLIKELY((Tdst)[__i].att.link_id))                     \
+               term_link_refcount_dec(Tpty, (Tdst)[__i].att.link_id, 1);     \
+             if (EINA_UNLIKELY((Tsrc)[__i].att.link_id))                     \
+               term_link_refcount_inc(Tpty, (Tsrc)[__i].att.link_id, 1);     \
+          }                                                                  \
      }                                                                       \
    memcpy(Tdst, Tsrc, N * sizeof(Termcell));                                 \
 } while (0)

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to