| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Skip over runs of ascii and such in a tight loop. This is one of the hottest functions and match_byte! adds extra branches for the common cases.
There was a problem hiding this comment.
This looks correct to me
Sorry, something went wrong.
| // These are the overwhelmingly common bytes, that we can just skip over in a tight loop. | ||
| static IS_SIMPLE_NAME_BYTE: [bool; 256] = { | ||
| let mut table = [false; 256]; | ||
| let mut i = 0; | ||
| while i < 256 { | ||
| table[i as usize] = matches!(i as u8, b'a'..=b'z' | b'A'..=b'Z' | b'0'..=b'9' | b'_' | b'-' | b'\xC0'..=b'\xEF'); | ||
| i += 1; | ||
| } | ||
| table | ||
| }; |
There was a problem hiding this comment.
Given that this is a table of bool you could also try a bitset, and see if that's any faster.
Sorry, something went wrong.
|
|
||
| // start_pos is the end of the previous token, therefore at a code point boundary | ||
| let start_pos = tokenizer.position(); | ||
| let mut value_bytes; |
There was a problem hiding this comment.
Nit: an explicit type annotation on value_bytes would nice.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Skip over runs of ascii and such in a tight loop. This is one of the hottest functions and match_byte! adds extra branches for the common cases.