Skip to content

Commit

Permalink
Use dummy as sentinel
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel committed Jul 15, 2024
1 parent f949d9a commit 4db8ad3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions crates/oxc_semantic/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub struct SemanticBuilder<'a> {

pub class_table_builder: ClassTableBuilder,

ast_node_records: Vec<Option<AstNodeId>>,
ast_node_records: Vec<AstNodeId>,
}

pub struct SemanticBuilderReturn<'a> {
Expand Down Expand Up @@ -251,13 +251,13 @@ impl<'a> SemanticBuilder<'a> {

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

fn retrieve_recorded_ast_node(&mut self) -> Option<AstNodeId> {
if self.cfg.is_some() {
self.ast_node_records.pop().expect("there is no ast node record to stop.")
Some(self.ast_node_records.pop().expect("there is no ast node record to stop."))
} else {
None
}
Expand All @@ -266,8 +266,8 @@ impl<'a> SemanticBuilder<'a> {
fn record_ast_node(&mut self) {
if self.cfg.is_some() {
if let Some(record) = self.ast_node_records.last_mut() {
if record.is_none() {
*record = Some(self.current_node_id);
if *record == AstNodeId::dummy() {
*record = self.current_node_id;
}
}
}
Expand Down

0 comments on commit 4db8ad3

Please sign in to comment.