mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 20:28:58 +00:00
perf(lexer): peak 2 bytes after ! (#8662)
`!==` and `!=` is very frequent. <img width="845" alt="image" src="https://github.com/user-attachments/assets/91ff20fc-ae1c-4fb9-9444-4eb90d8e95f3" /> Picked this up while profiling.
This commit is contained in:
parent
878ce10296
commit
3fa87ff6a6
1 changed files with 20 additions and 6 deletions
|
|
@ -209,14 +209,28 @@ ascii_byte_handler!(LIN(lexer) {
|
|||
// !
|
||||
ascii_byte_handler!(EXL(lexer) {
|
||||
lexer.consume_char();
|
||||
if lexer.next_ascii_byte_eq(b'=') {
|
||||
if lexer.next_ascii_byte_eq(b'=') {
|
||||
Kind::Neq2
|
||||
} else {
|
||||
Kind::Neq
|
||||
if let Some(next_2_bytes) = lexer.peek_2_bytes() {
|
||||
match next_2_bytes[0] {
|
||||
b'=' => {
|
||||
if next_2_bytes[1] == b'=' {
|
||||
lexer.consume_2_chars();
|
||||
Kind::Neq2
|
||||
} else {
|
||||
lexer.consume_char();
|
||||
Kind::Neq
|
||||
}
|
||||
}
|
||||
_ => Kind::Bang
|
||||
}
|
||||
} else {
|
||||
Kind::Bang
|
||||
// At EOF, or only 1 byte left
|
||||
match lexer.peek_byte() {
|
||||
Some(b'=') => {
|
||||
lexer.consume_char();
|
||||
Kind::Neq
|
||||
}
|
||||
_ => Kind::Bang
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue