From f9d3f2ef55f28a12a0fea66c0dd1ddcbd57c195f Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Mon, 15 Jul 2024 11:43:48 +0000 Subject: [PATCH] perf(semantic): inline ast record functions (#4272) Inline these functions so that when CFG is disabled, it doesn't cost a function call just for the trivial `if self.cfg.is_some()` check. Based on @rzvxa's suggestion in https://github.com/oxc-project/oxc/pull/4263#pullrequestreview-2176762670. --- crates/oxc_semantic/src/builder.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/oxc_semantic/src/builder.rs b/crates/oxc_semantic/src/builder.rs index 83138573480cf..5972d86faccde 100644 --- a/crates/oxc_semantic/src/builder.rs +++ b/crates/oxc_semantic/src/builder.rs @@ -249,12 +249,14 @@ impl<'a> SemanticBuilder<'a> { } } + #[inline] fn record_ast_nodes(&mut self) { if self.cfg.is_some() { self.ast_node_records.push(AstNodeId::dummy()); } } + #[inline] #[allow(clippy::unnecessary_wraps)] fn retrieve_recorded_ast_node(&mut self) -> Option { if self.cfg.is_some() { @@ -264,6 +266,7 @@ impl<'a> SemanticBuilder<'a> { } } + #[inline] fn record_ast_node(&mut self) { if self.cfg.is_some() { if let Some(record) = self.ast_node_records.last_mut() {