Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(semantic): do not record ast nodes for cfg if cfg disabled #4263

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions crates/oxc_semantic/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,18 +250,26 @@ impl<'a> SemanticBuilder<'a> {
}

fn record_ast_nodes(&mut self) {
self.ast_node_records.push(AstNodeId::dummy());
if self.cfg.is_some() {
self.ast_node_records.push(AstNodeId::dummy());
}
}

#[allow(clippy::unnecessary_wraps)]
fn retrieve_recorded_ast_node(&mut self) -> Option<AstNodeId> {
Some(self.ast_node_records.pop().expect("there is no ast node record to stop."))
if self.cfg.is_some() {
Some(self.ast_node_records.pop().expect("there is no ast node record to stop."))
} else {
None
}
}

fn record_ast_node(&mut self) {
if let Some(record) = self.ast_node_records.last_mut() {
if *record == AstNodeId::dummy() {
*record = self.current_node_id;
if self.cfg.is_some() {
if let Some(record) = self.ast_node_records.last_mut() {
if *record == AstNodeId::dummy() {
*record = self.current_node_id;
}
}
}
}
Expand Down
Loading