From 5398d986eff2084ecc166a6dc4d7ae3f62b9cd28 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Thu, 3 Oct 2019 11:09:21 +0200 Subject: [PATCH] tweaks: speed up determining the width of plain ASCII characters --- src/chars.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/chars.c b/src/chars.c index ca824a89..4b6c1427 100644 --- a/src/chars.c +++ b/src/chars.c @@ -201,9 +201,11 @@ char control_mbrep(const char *c, bool isdata) } #ifdef ENABLE_UTF8 -/* This function is equivalent to wcwidth() for multibyte characters. */ +/* Return the width in columns of the given (multibyte) character. */ int mbwidth(const char *c) { + /* Ask for the width only when the character isn't plain ASCII. */ + if ((signed char)*c <= 0) { wchar_t wc; int width; @@ -216,6 +218,8 @@ int mbwidth(const char *c) return 1; return width; + } else + return 1; } #endif