Open DimitrisJim opened 1 year ago
We can also do a very simple variant of this, instead of using a map we can just match
on the ascii characters instead, basically:
fn is_identifier_start(&self, c: char) -> bool {
match c {
'a'..='z' | 'A'..='Z' | '_' => true,
c if is_xid_start(c) => true,
_ => false
}
}
fn is_identifier_continuation(&self) -> bool {
match self.window[0] {
Some('a'..='z' | 'A'..='Z' | '_' | '0'..='9') => true,
Some(c) => is_xid_continue(c),
_ => false,
}
}
i.e, adding the 'a'..='z'
and 'A'..='Z'
cases.
Definitely an improvement here:
lexer time: [119.18 µs 119.26 µs 119.34 µs]
change: [-16.065% -14.664% -13.205%] (p = 0.00 < 0.05)
Performance has improved.
Found 7 outliers among 100 measurements (7.00%)
Reference: https://v8.dev/blog/scanner and https://v8.dev/blog/preparser (and probably others in the blog page)
Has some nice ideas on optimizations for the scanning and parsing phases.