summaryrefslogtreecommitdiffstats
path: root/input.c
diff options
context:
space:
mode:
authornicm <nicm>2017-02-08 16:45:18 +0000
committernicm <nicm>2017-02-08 16:45:18 +0000
commit13a0b6bb3fe05454cace81f5ec7624f6fd9021a5 (patch)
tree5b61257ae5a17983cc848ca01c1364d77f7dff7e /input.c
parentd4b006b9faf001de41560db2e8fb890c654598e2 (diff)
Collect sequences of printable ASCII characters and process them
together instead of handling them one by one. This is significantly faster. Sequences are terminated when we reach the end of the line, fill the internal buffer, or a different character is seen by the input parser (an escape sequence, or UTF-8). Rather than writing collected sequences out immediately, hold them until it is necessary (another screen modification, or we consume all available data). This means we can discard changes that would have no effect (for example, lines that would just be scrolled off the screen or cleared). This reduces the total amount of data we write out to the terminal - not important for fast terminals, but a big help with slow (like xterm).
Diffstat (limited to 'input.c')
-rw-r--r--input.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/input.c b/input.c
index 04dc8ce1..d5b8737d 100644
--- a/input.c
+++ b/input.c
@@ -896,6 +896,16 @@ input_parse(struct window_pane *wp)
}
/*
+ * Any state except print stops the current collection. This is
+ * an optimization to avoid checking if the attributes have
+ * changed for every character. It will stop unnecessarily for
+ * sequences that don't make a terminal change, but they should
+ * be the minority.
+ */
+ if (itr->handler != input_print)
+ screen_write_collect_end(&ictx->ctx);
+
+ /*
* Execute the handler, if any. Don't switch state if it
* returns non-zero.
*/
@@ -1020,7 +1030,7 @@ input_print(struct input_ctx *ictx)
ictx->cell.cell.attr &= ~GRID_ATTR_CHARSET;
utf8_set(&ictx->cell.cell.data, ictx->ch);
- screen_write_cell(&ictx->ctx, &ictx->cell.cell);
+ screen_write_collect_add(&ictx->ctx, &ictx->cell.cell);
ictx->cell.cell.attr &= ~GRID_ATTR_CHARSET;