mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 20:28:58 +00:00
perf(parser): speed up lexing non-decimal numbers (#4571)
Inline `Lexer::read_non_decimal` to reduce branching.
This commit is contained in:
parent
9e5be78af5
commit
bb33bcce35
2 changed files with 5 additions and 0 deletions
|
|
@ -206,6 +206,7 @@ impl Kind {
|
|||
)
|
||||
}
|
||||
|
||||
#[inline] // Inline into `read_non_decimal` - see comment there as to why
|
||||
pub fn matches_number_byte(self, b: u8) -> bool {
|
||||
match self {
|
||||
Decimal => b.is_ascii_digit(),
|
||||
|
|
|
|||
|
|
@ -39,6 +39,10 @@ impl<'a> Lexer<'a> {
|
|||
self.check_after_numeric_literal(kind)
|
||||
}
|
||||
|
||||
// Inline into the 3 calls from `read_zero` so that value of `kind` is known
|
||||
// and `kind.matches_number_byte` can be statically reduced to just the match arm
|
||||
// that applies for this specific kind. `matches_number_byte` is also marked `#[inline]`.
|
||||
#[inline]
|
||||
fn read_non_decimal(&mut self, kind: Kind) -> Kind {
|
||||
self.consume_char();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue