mirror of
https://github.com/tmux/tmux.git
synced 2025-09-03 06:17:04 +00:00
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).
This commit is contained in:
12
input.c
12
input.c
@ -895,6 +895,16 @@ input_parse(struct window_pane *wp)
|
||||
fatalx("no transition from state");
|
||||
}
|
||||
|
||||
/*
|
||||
* 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;
|
||||
|
||||
|
Reference in New Issue
Block a user