mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-04 04:06:06 -05:00
term: performance: use a bitfield to track which ascii printer to use
The things affecting which ASCII printer we use have grown... Instead of checking everything inside term_update_ascii_printer(), use a bitfield. Anything affecting the printer used, must now set a bit in this bitfield. This makes term_update_ascii_printer() much faster, since all it needs to do is check if the bitfield is zero or not.
This commit is contained in:
parent
22302d8bcc
commit
48cf57818d
5 changed files with 63 additions and 13 deletions
12
vt.c
12
vt.c
|
|
@ -243,12 +243,16 @@ action_execute(struct terminal *term, uint8_t c)
|
|||
case '\x0e':
|
||||
/* SO - shift out */
|
||||
term->charsets.selected = G1;
|
||||
term->bits_affecting_ascii_printer.charset =
|
||||
term->charsets.set[term->charsets.selected] != CHARSET_ASCII;
|
||||
term_update_ascii_printer(term);
|
||||
break;
|
||||
|
||||
case '\x0f':
|
||||
/* SI - shift in */
|
||||
term->charsets.selected = G0;
|
||||
term->bits_affecting_ascii_printer.charset =
|
||||
term->charsets.set[term->charsets.selected] != CHARSET_ASCII;
|
||||
term_update_ascii_printer(term);
|
||||
break;
|
||||
|
||||
|
|
@ -482,12 +486,16 @@ action_esc_dispatch(struct terminal *term, uint8_t final)
|
|||
case 'n':
|
||||
/* LS2 - Locking Shift 2 */
|
||||
term->charsets.selected = G2;
|
||||
term->bits_affecting_ascii_printer.charset =
|
||||
term->charsets.set[term->charsets.selected] != CHARSET_ASCII;
|
||||
term_update_ascii_printer(term);
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
/* LS3 - Locking Shift 3 */
|
||||
term->charsets.selected = G3;
|
||||
term->bits_affecting_ascii_printer.charset =
|
||||
term->charsets.set[term->charsets.selected] != CHARSET_ASCII;
|
||||
term_update_ascii_printer(term);
|
||||
break;
|
||||
|
||||
|
|
@ -546,6 +554,8 @@ action_esc_dispatch(struct terminal *term, uint8_t final)
|
|||
size_t idx = term->vt.private - '(';
|
||||
xassert(idx <= G3);
|
||||
term->charsets.set[idx] = CHARSET_GRAPHIC;
|
||||
term->bits_affecting_ascii_printer.charset =
|
||||
term->charsets.set[term->charsets.selected] != CHARSET_ASCII;
|
||||
term_update_ascii_printer(term);
|
||||
break;
|
||||
}
|
||||
|
|
@ -554,6 +564,8 @@ action_esc_dispatch(struct terminal *term, uint8_t final)
|
|||
size_t idx = term->vt.private - '(';
|
||||
xassert(idx <= G3);
|
||||
term->charsets.set[idx] = CHARSET_ASCII;
|
||||
term->bits_affecting_ascii_printer.charset =
|
||||
term->charsets.set[term->charsets.selected] != CHARSET_ASCII;
|
||||
term_update_ascii_printer(term);
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue