From 36669393e77b8322f387ba0b344fae860dd53717 Mon Sep 17 00:00:00 2001 From: Boshen Date: Thu, 29 Oct 2026 16:30:20 +0800 Subject: [PATCH] perf(parser): specialize identifier reference parsing (#28303) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Inline identifier parsing and bypass async/contextual disambiguation for ordinary identifiers. Native parse time versus parent: 2.7% lower with fresh arenas, 2.3% lower with reuse (geometric mean, 12 files, arm64 macOS; 3 rounds × 100 samples). Validated existing Rust/Node suites, parser/ESTree/token conformance, allocation snapshots, and x86 compilation. AI-assisted implementation. Depends on #28302. --- crates/oxc_parser/src/js/expression.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/oxc_parser/src/js/expression.rs b/crates/oxc_parser/src/js/expression.rs index 30b1c21521..a2ef8afef4 100644 --- a/crates/oxc_parser/src/js/expression.rs +++ b/crates/oxc_parser/src/js/expression.rs @@ -263,6 +263,10 @@ impl<'a, C: Config> ParserImpl<'a, C> { /// `TemplateLiteral`[?Yield, ?Await, ~Tagged] /// `CoverParenthesizedExpressionAndArrowParameterList`[?Yield, ?Await] fn parse_primary_expression(&mut self) -> Expression<'a> { + // Ordinary identifiers do not need async-function or contextual-keyword disambiguation. + if self.at(Kind::Ident) { + return self.parse_identifier_expression(); + } // FunctionExpression, GeneratorExpression // AsyncFunctionExpression, AsyncGeneratorExpression if self.at_function_with_async() {