vt: lazily reset utf8 in action_utf8_*_entry

action_clear() is in the super hot code path. Avoid resetting utf8
state there, as utf8 input is relatively uncommon.

Instead, reset it when we explicitly enter any of the utf8 collecting
states, as this is exactly the point where we need it.
This commit is contained in:
Daniel Eklöf 2020-04-27 15:50:44 +02:00
parent d1fc419e34
commit 3f3fff768a
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

7
vt.c
View file

@ -109,7 +109,6 @@ action_clear(struct terminal *term)
term->vt.params.idx = 0;
term->vt.private[0] = 0;
term->vt.private[1] = 0;
term->vt.utf8.idx = 0;
}
static void
@ -512,21 +511,21 @@ action_put(struct terminal *term, uint8_t c)
static void
action_utf8_2_entry(struct terminal *term, uint8_t c)
{
assert(term->vt.utf8.idx == 0);
term->vt.utf8.idx = 0;
term->vt.utf8.data[term->vt.utf8.idx++] = c;
}
static void
action_utf8_3_entry(struct terminal *term, uint8_t c)
{
assert(term->vt.utf8.idx == 0);
term->vt.utf8.idx = 0;
term->vt.utf8.data[term->vt.utf8.idx++] = c;
}
static void
action_utf8_4_entry(struct terminal *term, uint8_t c)
{
assert(term->vt.utf8.idx == 0);
term->vt.utf8.idx = 0;
term->vt.utf8.data[term->vt.utf8.idx++] = c;
}