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 7975c76 commit 6f48027
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 @@ -250,17 +250,17 @@ impl<'a> SemanticBuilder<'a> {
}

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

fn retrieve_recorded_ast_node(&mut self) -> Option<AstNodeId> {
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."))
}

fn record_ast_node(&mut self) {
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 6f48027

Please sign in to comment.