From 9f1495268c573e8203b8496fdc6f4ce1a8f5258d Mon Sep 17 00:00:00 2001 From: overlookmotel Date: Mon, 15 Jul 2024 12:04:10 +0100 Subject: [PATCH 1/3] perf(semantic): remove a branch from `record_ast_node` --- crates/oxc_semantic/src/builder.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/oxc_semantic/src/builder.rs b/crates/oxc_semantic/src/builder.rs index 5972d86faccde..717a9b4c0f4c4 100644 --- a/crates/oxc_semantic/src/builder.rs +++ b/crates/oxc_semantic/src/builder.rs @@ -268,11 +268,11 @@ 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() { - if *record == AstNodeId::dummy() { - *record = self.current_node_id; - } + // NB: If CFG is disabled, `ast_node_records` is always empty, so this is skipped. + // No need for a `if self.cfg.is_some()` guard. + if let Some(record) = self.ast_node_records.last_mut() { + if *record == AstNodeId::dummy() { + *record = self.current_node_id; } } } From 6adfb66e73837ba8b43f2cf698fd3fc70d30f571 Mon Sep 17 00:00:00 2001 From: overlookmotel Date: Mon, 15 Jul 2024 12:23:36 +0100 Subject: [PATCH 2/3] Dummy comment to re-run benchmark --- crates/oxc_semantic/src/builder.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/oxc_semantic/src/builder.rs b/crates/oxc_semantic/src/builder.rs index 717a9b4c0f4c4..aa53e8f051796 100644 --- a/crates/oxc_semantic/src/builder.rs +++ b/crates/oxc_semantic/src/builder.rs @@ -275,6 +275,7 @@ impl<'a> SemanticBuilder<'a> { *record = self.current_node_id; } } + // Dummy comment to re-run benchmark. TODO Remove me. } pub fn current_scope_flags(&self) -> ScopeFlags { From 019b4d36a745243fc49226f36abb7effa92facbc Mon Sep 17 00:00:00 2001 From: overlookmotel Date: Mon, 15 Jul 2024 12:24:23 +0100 Subject: [PATCH 3/3] Revert "Dummy comment to re-run benchmark" This reverts commit 788269e2b036f2eda19cd618b1d04d445c53c997. --- crates/oxc_semantic/src/builder.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/oxc_semantic/src/builder.rs b/crates/oxc_semantic/src/builder.rs index aa53e8f051796..717a9b4c0f4c4 100644 --- a/crates/oxc_semantic/src/builder.rs +++ b/crates/oxc_semantic/src/builder.rs @@ -275,7 +275,6 @@ impl<'a> SemanticBuilder<'a> { *record = self.current_node_id; } } - // Dummy comment to re-run benchmark. TODO Remove me. } pub fn current_scope_flags(&self) -> ScopeFlags {