From 234dd752dc2e15afab38cbbf78f8aa32be72ea5f Mon Sep 17 00:00:00 2001 From: Berke Güzel Date: Wed, 14 Oct 2026 14:42:25 +0300 Subject: Fast-path isolated single ASCII cell printing in term_feed_inner --- src/text.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/text.c') diff --git a/src/text.c b/src/text.c index 88b23a5..c72ea26 100644 --- a/src/text.c +++ b/src/text.c @@ -240,6 +240,19 @@ static void term_feed_inner(struct term *t, const char *buf, size_t len, unsigne } } } + if (run == 1) { + if (i + 1 < len && (unsigned char)buf[i + 1] >= 0xc2 && + (unsigned char)buf[i + 1] <= 0xf4 && + (i + 2 == len || ((unsigned char)buf[i + 2] & 0xc0) == 0x80)) { + uint32_t next_cp; + if (utf8_decode_one(buf + i + 1, len - i - 1, &next_cp) && + term_text_class(next_cp) > 0 && + try_text_run(t, buf, len, &i)) + continue; + } + sc_print_cell(t, ch, 1, cur_flags); + continue; + } if (i + (size_t)run < len && (unsigned char)buf[i + run] >= 0x80) { uint32_t next_cp; if (utf8_decode_one(buf + i + run, len - i - (size_t)run, &next_cp) && -- cgit v1.2.3