From 19577709dbcfc9761cfcb1b39ec7f3ebdc810285 Mon Sep 17 00:00:00 2001 From: overlookmotel Date: Fri, 29 Dec 2023 02:07:21 +0000 Subject: [PATCH] Remove redundant code from lexer (#1850) Just removes a couple of lines of redundant code from the lexer. A note on the 2nd one: ```rs let mut builder = AutoCow::new(lexer); let c = lexer.consume_char(); builder.push_matching(c); ``` `push_matching()` is a no-op unless `force_allocation_without_current_ascii_char()` has already been called. Here the `AutoCow` has just been freshly created, so we know it hasn't. --- crates/oxc_parser/src/lexer/mod.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/crates/oxc_parser/src/lexer/mod.rs b/crates/oxc_parser/src/lexer/mod.rs index 0858d5712ae77..46de999bd560a 100644 --- a/crates/oxc_parser/src/lexer/mod.rs +++ b/crates/oxc_parser/src/lexer/mod.rs @@ -321,8 +321,6 @@ impl<'a> Lexer<'a> { /// Read each char and set the current token /// Whitespace and line terminators are skipped fn read_next_token(&mut self) -> Kind { - self.current.token.start = self.offset(); - loop { let offset = self.offset(); self.current.token.start = offset; @@ -1587,8 +1585,7 @@ const BTO: ByteHandler = |lexer| { // \ const ESC: ByteHandler = |lexer| { let mut builder = AutoCow::new(lexer); - let c = lexer.consume_char(); - builder.push_matching(c); + lexer.consume_char(); builder.force_allocation_without_current_ascii_char(lexer); lexer.identifier_unicode_escape_sequence(&mut builder, true); let text = lexer.identifier_name(builder);