From f031c8282dadd17ef4157cba2810a84b079c19b9 Mon Sep 17 00:00:00 2001 From: Bruno Andreotti Date: Thu, 16 May 2024 09:40:12 -0300 Subject: [PATCH] Don't store duplicate outbound premises --- carcara/src/ast/node.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/carcara/src/ast/node.rs b/carcara/src/ast/node.rs index 97bac2e1..d657bd91 100644 --- a/carcara/src/ast/node.rs +++ b/carcara/src/ast/node.rs @@ -128,14 +128,14 @@ pub fn proof_list_to_node(commands: Vec) -> Rc { commands: std::vec::IntoIter, accumulator: Vec>, args: Vec, - outbound_premises: Vec>, + outbound_premises: IndexSet>, } let mut stack: Vec = vec![Frame { commands: commands.into_iter(), accumulator: Vec::new(), args: Vec::new(), - outbound_premises: Vec::new(), + outbound_premises: IndexSet::new(), }]; let new_root_proof = loop { @@ -159,7 +159,7 @@ pub fn proof_list_to_node(commands: Vec) -> Rc { for p in &premises { if p.depth() < stack.len() - 1 { let frame = stack.last_mut().unwrap(); - frame.outbound_premises.push(p.clone()); + frame.outbound_premises.insert(p.clone()); } } @@ -186,7 +186,7 @@ pub fn proof_list_to_node(commands: Vec) -> Rc { commands: s.commands.into_iter(), accumulator: Vec::new(), args: s.args, - outbound_premises: Vec::new(), + outbound_premises: IndexSet::new(), }; stack.push(frame); continue; @@ -202,14 +202,14 @@ pub fn proof_list_to_node(commands: Vec) -> Rc { for p in &frame.outbound_premises { if p.depth() < stack.len() - 1 { let frame = stack.last_mut().unwrap(); - frame.outbound_premises.push(p.clone()); + frame.outbound_premises.insert(p.clone()); } } ProofNode::Subproof(SubproofNode { last_step: frame.accumulator.pop().unwrap(), args: frame.args, - outbound_premises: frame.outbound_premises, + outbound_premises: frame.outbound_premises.into_iter().collect(), }) } };