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

@ -2335,6 +2335,7 @@ term_restore_cursor(struct terminal *term, const struct cursor *cursor)
term->vt.attrs = term->vt.saved_attrs;
term->charsets = term->saved_charsets;
term->charset = term->charsets.set[term->charsets.selected];
}
void