Skip to content

Commit

Permalink
refactor(parser): convert lexer byte handler for | to a single match (
Browse files Browse the repository at this point in the history
#4575)

Same as #4573 and #4574. Convert lexer's byte handler for `|` to a single match rather than multiple `next_ascii_byte_eq` calls.
  • Loading branch information
overlookmotel committed Jul 31, 2024
1 parent bba824b commit e68ed62
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions crates/oxc_parser/src/lexer/byte_handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,16 +495,21 @@ ascii_byte_handler!(BEO(lexer) {
// |
ascii_byte_handler!(PIP(lexer) {
lexer.consume_char();
if lexer.next_ascii_byte_eq(b'|') {
if lexer.next_ascii_byte_eq(b'=') {
Kind::Pipe2Eq
} else {
Kind::Pipe2

match lexer.peek_byte() {
Some(b'|') => {
lexer.consume_char();
if lexer.next_ascii_byte_eq(b'=') {
Kind::Pipe2Eq
} else {
Kind::Pipe2
}
}
} else if lexer.next_ascii_byte_eq(b'=') {
Kind::PipeEq
} else {
Kind::Pipe
Some(b'=') => {
lexer.consume_char();
Kind::PipeEq
}
_ => Kind::Pipe
}
});

Expand Down

0 comments on commit e68ed62

Please sign in to comment.