term: cache currently selected charset

vt.c::action_print(), which is in the hot path, needs to lookup the
currently selected charset.

This currently requires two loads; first to load the current
charset *index*, and then another to get _which_ charset is currently
mapped to that index.

By caching the current charset, we only need one load.

We need to update the cache when:

* A different charset index is selected (i.e. SO/SI)
* The charset for the current index is changed (e.g. ‘\E(0’, ‘\E(B’
  etc)
* We restore saved charsets
This commit is contained in:
Daniel Eklöf 2021-03-14 14:32:00 +01:00
parent c5c3447ca8
commit aa8902a6ef
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
3 changed files with 12 additions and 6 deletions

View file

@ -280,6 +280,7 @@ struct terminal {
struct charsets charsets;
struct charsets saved_charsets; /* For save/restore cursor + attributes */
enum charset charset; /* cached copy of charsets.set[charsets.selected] */
bool auto_margin;
bool insert_mode;