:: commit 8bd7cf743cca754bf220f61ec422011746698542

mintsuki <mintsuki@protonmail.com> — 2021-04-08 21:41

parents: 55a88438f4

gterm: Speed up terminal greatly by only printing on screen characters that changed

diff --git a/stage23/lib/gterm.c b/stage23/lib/gterm.c
index cbf4fe7b..9c9fa5d0 100644
--- a/stage23/lib/gterm.c
+++ b/stage23/lib/gterm.c
@@ -181,7 +181,8 @@ static void scroll(void) {
     clear_cursor();
 
     for (int i = cols; i < rows * cols; i++) {
-        plot_char_grid(&grid[i], (i - cols) % cols, (i - cols) / cols);
+        if (memcmp(&grid[i], &grid[i - cols], sizeof(struct gterm_char) != 0))
+            plot_char_grid(&grid[i], (i - cols) % cols, (i - cols) / cols);
     }
 
     // Clear the last line of the screen.
@@ -190,7 +191,8 @@ static void scroll(void) {
     empty.fg = 9;
     empty.bg = 8;
     for (int i = rows * cols - cols; i < rows * cols; i++) {
-        plot_char_grid(&empty, i % cols, i / cols);
+        if (memcmp(&grid[i], &empty, sizeof(struct gterm_char) != 0))
+            plot_char_grid(&empty, i % cols, i / cols);
     }
 
     draw_cursor();
tab: 248 wrap: offon