mirror of
https://github.com/danbulant/oxc
synced 2026-05-21 05:08:45 +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) {
|
ascii_byte_handler!(EXL(lexer) {
|
||||||
lexer.consume_char();
|
lexer.consume_char();
|
||||||
if lexer.next_ascii_byte_eq(b'=') {
|
if let Some(next_2_bytes) = lexer.peek_2_bytes() {
|
||||||
if lexer.next_ascii_byte_eq(b'=') {
|
match next_2_bytes[0] {
|
||||||
Kind::Neq2
|
b'=' => {
|
||||||
} else {
|
if next_2_bytes[1] == b'=' {
|
||||||
Kind::Neq
|
lexer.consume_2_chars();
|
||||||
|
Kind::Neq2
|
||||||
|
} else {
|
||||||
|
lexer.consume_char();
|
||||||
|
Kind::Neq
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => Kind::Bang
|
||||||
}
|
}
|
||||||
} else {
|
} 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