From b2c63c3d3c59f717d30533cae6aafd10f3e710c9 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Thu, 12 Mar 2020 15:42:52 +0100 Subject: [PATCH] chars: optimize a function for the most common blanks: space and tab Also, do not bother to provide separate code for the non-UTF-8 case. Instead, optimize for plain ASCII characters. --- src/chars.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/chars.c b/src/chars.c index 8cd7610d..1f5c7195 100644 --- a/src/chars.c +++ b/src/chars.c @@ -79,17 +79,15 @@ bool is_alnum_char(const char *c) /* Return TRUE when the given character is space or tab or other whitespace. */ bool is_blank_char(const char *c) { -#ifdef ENABLE_UTF8 - if (use_utf8) { wchar_t wc; + if ((signed char)*c >= 0) + return (*c == ' ' || *c == TAB_CODE); + if (mbtowc(&wc, c, MAXCHARLEN) < 0) return FALSE; return iswblank(wc); - } else -#endif - return isblank((unsigned char)*c); } /* Return TRUE when the given character is a control character. */