nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit b2c63c3d3c59f717d30533cae6aafd10f3e710c9
parent ae139021eb7044365aefa3cf03a89a2631334e4d
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Thu, 12 Mar 2020 15:42:52 +0100

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.

Diffstat:
Msrc/chars.c | 8+++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git 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. */