From 3f3fff768aebe4d1a7822bbe3ecc3e68a3023c8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 27 Apr 2020 15:50:44 +0200 Subject: [PATCH] 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. --- vt.c | 7 +++---- 1 file 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; }