diff --git a/crates/oxc_ast/src/ast_builder.rs b/crates/oxc_ast/src/ast_builder.rs index c7119691e..fb9f8c7c9 100644 --- a/crates/oxc_ast/src/ast_builder.rs +++ b/crates/oxc_ast/src/ast_builder.rs @@ -16,6 +16,7 @@ impl<'a> AstBuilder<'a> { Self { allocator } } + #[inline] pub fn alloc(&self, value: T) -> Box<'a, T> { Box(self.allocator.alloc(value)) } diff --git a/crates/oxc_parser/src/js/expression.rs b/crates/oxc_parser/src/js/expression.rs index addf0ffa5..7104f3fa5 100644 --- a/crates/oxc_parser/src/js/expression.rs +++ b/crates/oxc_parser/src/js/expression.rs @@ -458,8 +458,8 @@ impl<'a> Parser<'a> { in_optional_chain: &mut bool, ) -> Result> { let node = self.start_node(); - let lhs = self.parse_primary_expression()?; - self.parse_member_expression_rhs(node, lhs, in_optional_chain) + self.parse_primary_expression() + .and_then(|lhs| self.parse_member_expression_rhs(node, lhs, in_optional_chain)) } /// Section 13.3 Super Call diff --git a/crates/oxc_parser/src/js/function.rs b/crates/oxc_parser/src/js/function.rs index 9e6da6d55..947ea5547 100644 --- a/crates/oxc_parser/src/js/function.rs +++ b/crates/oxc_parser/src/js/function.rs @@ -106,7 +106,7 @@ impl<'a> Parser<'a> { let return_type = self.parse_ts_return_type_annotation()?; - let body = self.at(Kind::LCurly).then(|| self.parse_function_body()).transpose()?; + let body = if self.at(Kind::LCurly) { Some(self.parse_function_body()?) } else { None }; self.ctx = self.ctx.and_await(has_await).and_yield(has_yield); diff --git a/crates/oxc_parser/src/lexer/mod.rs b/crates/oxc_parser/src/lexer/mod.rs index 302850b41..687bfcba0 100644 --- a/crates/oxc_parser/src/lexer/mod.rs +++ b/crates/oxc_parser/src/lexer/mod.rs @@ -84,7 +84,7 @@ impl<'a> Lexer<'a> { source_type, current, errors, - lookahead: VecDeque::new(), + lookahead: VecDeque::with_capacity(4), context: LexerContext::Regular, } } @@ -499,7 +499,7 @@ impl<'a> Lexer<'a> { fn skip_multi_line_comment(&mut self) -> Kind { let remaining = self.remaining().as_bytes(); let newline = self.current.token.is_on_new_line; - let state = SkipMultilineComment::new(newline, remaining).simd(remaining); + let state = SkipMultilineComment::new(newline, remaining).simd(); // SAFETY: offset is computed to the boundary self.current.chars = diff --git a/crates/oxc_parser/src/lexer/simd.rs b/crates/oxc_parser/src/lexer/simd.rs index fd046922b..8df552cb3 100644 --- a/crates/oxc_parser/src/lexer/simd.rs +++ b/crates/oxc_parser/src/lexer/simd.rs @@ -119,8 +119,8 @@ impl<'a> SkipMultilineComment<'a> { } } - pub fn simd(mut self, remaining: &[u8]) -> Self { - let (chunks, remainder) = remaining.as_chunks::(); + pub fn simd(mut self) -> Self { + let (chunks, remainder) = self.remaining.as_chunks::(); for chunk in chunks { self.check(chunk, chunk.len());