gbranden pushed a commit to branch master
in repository groff.

commit ce96328eef91610b2e11a6e54965a3ae613d795a
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Nov 22 00:33:20 2026 -0600

    src/devices/grotty/tty.cpp: Drop v/vpos caching.
    
    * src/devices/grotty/tty.cpp (tty_printer::add_char): Refactor.  Drop
      caching of vertical drawing position (`cached_v`) and its quantization
      to a terminal line number (`cached_vpos`).  Doing so is a complication
      that seems to produce no performance improvement.
    
    This commit omits an indentation update to clarify the logic change.
    
    Performance measurement method:
    
    First generate a lot of "grout" for grotty to read.
    
    $ time groff -m an -T utf8 -Z 64bashes.man > 64bashes.grout
    
    Then measure grotty's performance.
    
    Before:
    
    $ time ./build/grotty 64bashes.grout >/dev/null
    
    real    0m5.507s
    user    0m5.251s
    sys     0m0.256s
    
    After:
    
    $ time ./build/grotty 64bashes.grout >/dev/null
    
    real    0m5.177s
    user    0m4.896s
    sys     0m0.281s
    
    The resulting net performance _improvement_ might be due to reduced
    register pressure, but I did not investigate this possibility.
---
 ChangeLog                  |  8 ++++++++
 src/devices/grotty/tty.cpp | 11 +----------
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index df3a7d73d..2081831e6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2026-11-22  G. Branden Robinson <[email protected]>
+
+       * src/devices/grotty/tty.cpp (tty_printer::add_char): Refactor.
+       Drop caching of vertical drawing position (`cached_v`) and its
+       quantization to a terminal line number (`cached_vpos`).  Doing
+       so is a complication that seems to produce no performance
+       improvement.
+
 2026-11-22  G. Branden Robinson <[email protected]>
 
        * src/devices/grotty/tty.cpp (tty_printer::add_char): Refactor.
diff --git a/src/devices/grotty/tty.cpp b/src/devices/grotty/tty.cpp
index 7b1fb29bb..55c80c7c3 100644
--- a/src/devices/grotty/tty.cpp
+++ b/src/devices/grotty/tty.cpp
@@ -202,8 +202,6 @@ public:
 class tty_printer : public printer {
   tty_glyph **lines;
   int nlines;
-  int cached_v;
-  int cached_vpos;
   long curr_fore_idx;
   long curr_back_idx;
   bool is_underlining;
@@ -298,7 +296,7 @@ bool tty_printer::has_color(unsigned int r,
   return is_known_color;
 }
 
-tty_printer::tty_printer() : cached_v(0)
+tty_printer::tty_printer()
 {
   if (font::is_unicode) {
     hline_char = 0x2500;
@@ -422,10 +420,6 @@ void tty_printer::add_char(output_character c, int w,
   if ((v % font::vert) != 0)
     fatal("vertical position not a multiple of vertical motion"
          " quantum");
-  if ((v == cached_v) && (cached_v != 0))
-    vpos = cached_vpos;
-  else {
-    vpos = v / font::vert;
     if (vpos > nlines) {
       tty_glyph **old_lines = lines;
       // If we exceed the previous page length, double the size so that
@@ -449,9 +443,6 @@ void tty_printer::add_char(output_character c, int w,
       delete[] old_lines;
       nlines = new_nlines;
     }
-    cached_v = v;
-    cached_vpos = vpos;
-  }
   tty_glyph *g = 0 /* nullptr */;
   try {
     g = new tty_glyph;

_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to