Skip to content

Commit

Permalink
perf(semantic): inline ast record functions (#4272)
Browse files Browse the repository at this point in the history
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 #4263 (review).
  • Loading branch information
overlookmotel committed Jul 15, 2024
1 parent 9a87e41 commit f9d3f2e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crates/oxc_semantic/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<AstNodeId> {
if self.cfg.is_some() {
Expand All @@ -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() {
Expand Down

0 comments on commit f9d3f2e

Please sign in to comment.