From bf42158ad7a7f662679c459ec489a5b2a2743d5b Mon Sep 17 00:00:00 2001 From: Boshen Date: Tue, 5 Mar 2024 15:39:53 +0800 Subject: [PATCH] perf(parser): inline `end_span` and `parse_identifier_kind` which are on the hot path (#2612) --- Cargo.toml | 4 ++-- crates/oxc_parser/src/cursor.rs | 4 ++-- crates/oxc_parser/src/js/expression.rs | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d01e83950..f98a6b717 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -146,8 +146,8 @@ opt-level = 'z' opt-level = 3 lto = "fat" codegen-units = 1 -strip = "symbols" -debug = false +strip = false +debug = true panic = "abort" # Let it crash and force ourselves to write safe Rust. # Use the `--profile release-debug` flag to show symbols in release mode. diff --git a/crates/oxc_parser/src/cursor.rs b/crates/oxc_parser/src/cursor.rs index 44692dc9b..ad4fab7d3 100644 --- a/crates/oxc_parser/src/cursor.rs +++ b/crates/oxc_parser/src/cursor.rs @@ -24,8 +24,8 @@ impl<'a> ParserImpl<'a> { Span::new(token.start, 0) } - pub(crate) fn end_span(&self, span: Span) -> Span { - let mut span = span; + #[inline] + pub(crate) fn end_span(&self, mut span: Span) -> Span { span.end = self.prev_token_end; span } diff --git a/crates/oxc_parser/src/js/expression.rs b/crates/oxc_parser/src/js/expression.rs index 7fb35f020..133639165 100644 --- a/crates/oxc_parser/src/js/expression.rs +++ b/crates/oxc_parser/src/js/expression.rs @@ -102,6 +102,7 @@ impl<'a> ParserImpl<'a> { IdentifierName { span, name } } + #[inline] pub(crate) fn parse_identifier_kind(&mut self, kind: Kind) -> (Span, Atom<'a>) { let span = self.start_span(); let name = self.cur_string();