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.master
parent
ae139021eb
commit
b2c63c3d3c
|
@ -79,17 +79,15 @@ bool is_alnum_char(const char *c)
|
||||||
/* Return TRUE when the given character is space or tab or other whitespace. */
|
/* Return TRUE when the given character is space or tab or other whitespace. */
|
||||||
bool is_blank_char(const char *c)
|
bool is_blank_char(const char *c)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_UTF8
|
|
||||||
if (use_utf8) {
|
|
||||||
wchar_t wc;
|
wchar_t wc;
|
||||||
|
|
||||||
|
if ((signed char)*c >= 0)
|
||||||
|
return (*c == ' ' || *c == TAB_CODE);
|
||||||
|
|
||||||
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
|
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return iswblank(wc);
|
return iswblank(wc);
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
return isblank((unsigned char)*c);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return TRUE when the given character is a control character. */
|
/* Return TRUE when the given character is a control character. */
|
||||||
|
|
Loading…
Reference in New Issue