From 66676c7030ce2e71f90713290cb39459f78d61d9 Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Sun, 4 Sep 2016 13:09:25 +1000 Subject: [PATCH] Add a fast path for utf8_width() For common ASCII characters Signed-off-by: Steve Bennett --- utf8.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/utf8.c b/utf8.c index 966ca85..0edf450 100644 --- a/utf8.c +++ b/utf8.c @@ -212,6 +212,10 @@ static int utf8_in_range(const struct utf8range *range, int num, int ch) int utf8_width(int ch) { + /* short circuit for common case */ + if (isascii(ch)) { + return 1; + } if (utf8_in_range(unicode_range_combining, ARRAYSIZE(unicode_range_combining), ch)) { return 0; } -- 2.44.0