From e68ed628b8abcb3352fb3979f7cccb20edb2c912 Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Wed, 31 Jul 2024 03:32:59 +0000 Subject: [PATCH] refactor(parser): convert lexer byte handler for `|` to a single match (#4575) Same as #4573 and #4574. Convert lexer's byte handler for `|` to a single match rather than multiple `next_ascii_byte_eq` calls. --- crates/oxc_parser/src/lexer/byte_handlers.rs | 23 ++++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/crates/oxc_parser/src/lexer/byte_handlers.rs b/crates/oxc_parser/src/lexer/byte_handlers.rs index 1e9a420b6..b7102a89f 100644 --- a/crates/oxc_parser/src/lexer/byte_handlers.rs +++ b/crates/oxc_parser/src/lexer/byte_handlers.rs @@ -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 } });