aboutsummaryrefslogtreecommitdiff
path: root/vt.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-04-27 13:50:44 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-04-27 13:50:44 +0000
commit3f3fff768aebe4d1a7822bbe3ecc3e68a3023c8f (patch)
tree0daab7006eae1bbd06b378052bf6fdf067214322 /vt.c
parentvt: action_utf8_print: idx is cleared in action_clear() (diff)
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.
Diffstat (limited to 'vt.c')
-rw-r--r--vt.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/vt.c b/vt.c
index 3dcb2f57..743580a1 100644
--- a/vt.c
+++ b/vt.c
@@ -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;
}