mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
Optimize rune_is_* procedures for tokenizer
This commit is contained in:
+4
-2
@@ -937,8 +937,10 @@ Token tokenizer_get_token(Tokenizer *t) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Token token = {};
|
Token token = {};
|
||||||
token.string = {t->curr, 1};
|
token.string.text = t->curr;
|
||||||
token.pos.file = t->fullpath;
|
token.string.len = 1;
|
||||||
|
token.pos.file.text = t->fullpath.text;
|
||||||
|
token.pos.file.len = t->fullpath.len;
|
||||||
token.pos.line = t->line_count;
|
token.pos.line = t->line_count;
|
||||||
token.pos.offset = t->curr - t->start;
|
token.pos.offset = t->curr - t->start;
|
||||||
token.pos.column = t->curr - t->line + 1;
|
token.pos.column = t->curr - t->line + 1;
|
||||||
|
|||||||
+2
-2
@@ -12,7 +12,7 @@ bool rune_is_letter(Rune r) {
|
|||||||
if (r == '_') {
|
if (r == '_') {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return gb_char_is_alpha(cast(char)r) != 0;
|
return ((cast(u32)r | 0x20) - 0x61) < 26;
|
||||||
}
|
}
|
||||||
switch (utf8proc_category(r)) {
|
switch (utf8proc_category(r)) {
|
||||||
case UTF8PROC_CATEGORY_LU:
|
case UTF8PROC_CATEGORY_LU:
|
||||||
@@ -27,7 +27,7 @@ bool rune_is_letter(Rune r) {
|
|||||||
|
|
||||||
bool rune_is_digit(Rune r) {
|
bool rune_is_digit(Rune r) {
|
||||||
if (r < 0x80) {
|
if (r < 0x80) {
|
||||||
return gb_is_between(r, '0', '9');
|
return (cast(u32)r - '0') < 10;
|
||||||
}
|
}
|
||||||
return utf8proc_category(r) == UTF8PROC_CATEGORY_ND;
|
return utf8proc_category(r) == UTF8PROC_CATEGORY_ND;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user