aboutsummaryrefslogtreecommitdiff
path: root/src/unicode.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2020-05-27 12:43:49 +0100
committergingerBill <bill@gingerbill.org>2020-05-27 12:43:49 +0100
commit4e21a4d46a90c56edd45f5d5c46b375742738a17 (patch)
tree0c990870c713c366818d4ae94589e81d021f1ead /src/unicode.cpp
parent6ac0fb80a6eab6ba28838e8e577dc8ae8cba06a7 (diff)
Optimize `rune_is_*` procedures for tokenizer
Diffstat (limited to 'src/unicode.cpp')
-rw-r--r--src/unicode.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/unicode.cpp b/src/unicode.cpp
index 679d56365..b988155f7 100644
--- a/src/unicode.cpp
+++ b/src/unicode.cpp
@@ -12,7 +12,7 @@ bool rune_is_letter(Rune r) {
if (r == '_') {
return true;
}
- return gb_char_is_alpha(cast(char)r) != 0;
+ return ((cast(u32)r | 0x20) - 0x61) < 26;
}
switch (utf8proc_category(r)) {
case UTF8PROC_CATEGORY_LU:
@@ -27,7 +27,7 @@ bool rune_is_letter(Rune r) {
bool rune_is_digit(Rune r) {
if (r < 0x80) {
- return gb_is_between(r, '0', '9');
+ return (cast(u32)r - '0') < 10;
}
return utf8proc_category(r) == UTF8PROC_CATEGORY_ND;
}