Avoid calling iswalnum for ascii characters
iswalnum can be pretty expensive as its a shared library call.
This commit is contained in:
parent
c97add7f5a
commit
707904a91b
|
@ -60,12 +60,23 @@ inline bool is_blank(Codepoint c) noexcept
|
|||
is_horizontal_blank(c) ;
|
||||
}
|
||||
|
||||
inline bool is_basic_alpha(Codepoint c) noexcept
|
||||
{
|
||||
return (c >= 'a' and c <= 'z') or (c >= 'A' and c <= 'Z');
|
||||
}
|
||||
|
||||
inline bool is_basic_digit(Codepoint c) noexcept
|
||||
{
|
||||
return c >= '0' and c <= '9';
|
||||
}
|
||||
|
||||
enum WordType { Word, WORD };
|
||||
|
||||
template<WordType word_type = Word>
|
||||
inline bool is_word(Codepoint c, ConstArrayView<Codepoint> extra_word_chars = {'_'}) noexcept
|
||||
{
|
||||
return iswalnum((wchar_t)c) or contains(extra_word_chars, c);
|
||||
return (c < 128 ? is_basic_alpha(c) or is_basic_digit(c) : iswalnum((wchar_t)c)) or
|
||||
contains(extra_word_chars, c);
|
||||
}
|
||||
|
||||
template<>
|
||||
|
@ -79,16 +90,6 @@ inline bool is_punctuation(Codepoint c, ConstArrayView<Codepoint> extra_word_cha
|
|||
return not (is_word(c, extra_word_chars) or is_blank(c));
|
||||
}
|
||||
|
||||
inline bool is_basic_alpha(Codepoint c) noexcept
|
||||
{
|
||||
return (c >= 'a' and c <= 'z') or (c >= 'A' and c <= 'Z');
|
||||
}
|
||||
|
||||
inline bool is_basic_digit(Codepoint c) noexcept
|
||||
{
|
||||
return c >= '0' and c <= '9';
|
||||
}
|
||||
|
||||
inline bool is_identifier(Codepoint c) noexcept
|
||||
{
|
||||
return is_basic_alpha(c) or is_basic_digit(c) or
|
||||
|
|
Loading…
Reference in New Issue
Block a user