term: runtime switch between a ‘fast’ and a ‘generic’ ASCII print function

term_print() is called whenever the client application “prints”
something to the grid. It is called for both ASCII and UTF-8
characters, and needs to handle sixels, insert mode and ASCII
vs. graphical charsets.

Since it’s on the hot path, this becomes unnecessarily slow.

This patch adds a “fast” version of term_print(), tailored for the
common case: ASCII characters in non-insert mode, without any sixels
and non-graphical charsets.

A new function, term_update_ascii_printer(), has been added, and must
be called whenever:

* The currently selected charset *index* changes
* The currently selected charset changes (from ASCII to graphical, or
  vice verse)
* Sixels are added to the grid
* Sixels are removed from the grid
* Insert mode is enabled/disabled
This commit is contained in:
Daniel Eklöf 2021-03-14 19:19:10 +01:00
parent d8f0e701b5
commit 60b3ccc641
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
5 changed files with 84 additions and 16 deletions

2
csi.c
View file

@ -1136,6 +1136,7 @@ csi_dispatch(struct terminal *term, uint8_t final)
case 4: /* Insert Mode - IRM */
term->insert_mode = true;
term_update_ascii_printer(term);
break;
case 12: /* Send/receive Mode - SRM */
@ -1156,6 +1157,7 @@ csi_dispatch(struct terminal *term, uint8_t final)
switch (vt_param_get(term, 0, 0)) {
case 4: /* Insert Mode - IRM */
term->insert_mode = false;
term_update_ascii_printer(term);
break;
case 2: /* Keyboard Action Mode - AM */