diff --git a/src/regex_impl.cc b/src/regex_impl.cc index 9d7d98ab..cf22130b 100644 --- a/src/regex_impl.cc +++ b/src/regex_impl.cc @@ -1091,23 +1091,14 @@ bool is_character_class(const CharacterClass& character_class, Codepoint cp) bool is_ctype(CharacterType ctype, Codepoint cp) { - if ((ctype & CharacterType::Digit) and iswdigit(cp)) - return true; - if ((ctype & CharacterType::Word) and is_word(cp)) - return true; - if ((ctype & CharacterType::Whitespace) and is_blank(cp)) - return true; - if ((ctype & CharacterType::HorizontalWhitespace) and is_horizontal_blank(cp)) - return true; - if ((ctype & CharacterType::NotDigit) and not iswdigit(cp)) - return true; - if ((ctype & CharacterType::NotWord) and not is_word(cp)) - return true; - if ((ctype & CharacterType::NotWhitespace) and not is_blank(cp)) - return true; - if ((ctype & CharacterType::NotHorizontalWhitespace) and not is_horizontal_blank(cp)) - return true; - return false; + return ((ctype & CharacterType::Whitespace) and is_blank(cp)) or + ((ctype & CharacterType::HorizontalWhitespace) and is_horizontal_blank(cp)) or + ((ctype & CharacterType::Digit) and iswdigit(cp)) or + ((ctype & CharacterType::Word) and is_word(cp)) or + ((ctype & CharacterType::NotWhitespace) and not is_blank(cp)) or + ((ctype & CharacterType::NotHorizontalWhitespace) and not is_horizontal_blank(cp)) or + ((ctype & CharacterType::NotDigit) and not iswdigit(cp)) or + ((ctype & CharacterType::NotWord) and not is_word(cp)); } namespace diff --git a/src/regex_impl.hh b/src/regex_impl.hh index 6c687e4f..a2575ca6 100644 --- a/src/regex_impl.hh +++ b/src/regex_impl.hh @@ -26,13 +26,13 @@ enum class MatchDirection enum class CharacterType : unsigned char { None = 0, - Word = 1 << 0, - Whitespace = 1 << 1, - HorizontalWhitespace = 1 << 2, + Whitespace = 1 << 0, + HorizontalWhitespace = 1 << 1, + Word = 1 << 2, Digit = 1 << 3, - NotWord = 1 << 4, - NotWhitespace = 1 << 5, - NotHorizontalWhitespace = 1 << 6, + NotWhitespace = 1 << 4, + NotHorizontalWhitespace = 1 << 5, + NotWord = 1 << 6, NotDigit = 1 << 7 }; constexpr bool with_bit_ops(Meta::Type) { return true; }