From 84e221569e4f3a059d6e9606190d6058d72dc4e3 Mon Sep 17 00:00:00 2001 From: oflatt Date: Mon, 11 Dec 2023 15:30:24 -0800 Subject: [PATCH] more cleanup --- src/extract/faster_bottom_up.rs | 12 ++++++------ src/extract/greedy_dag_1.rs | 2 -- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/extract/faster_bottom_up.rs b/src/extract/faster_bottom_up.rs index 87dc362..d4c1d19 100644 --- a/src/extract/faster_bottom_up.rs +++ b/src/extract/faster_bottom_up.rs @@ -16,22 +16,22 @@ pub struct BottomUpExtractor; impl Extractor for BottomUpExtractor { fn extract(&self, egraph: &EGraph, _roots: &[ClassId]) -> ExtractionResult { - // 1. build map from class to parent nodes let mut parents = IndexMap::>::default(); let n2c = |nid: &NodeId| egraph.nid_to_cid(nid); let mut analysis_pending = UniqueQueue::default(); + for class in egraph.classes().values() { + parents.insert(class.id.clone(), Vec::new()); + } + for class in egraph.classes().values() { for node in &class.nodes { for c in &egraph[node].children { // compute parents of this enode - parents - .entry(n2c(c).clone()) - .or_default() - .push(node.clone()); + parents[n2c(c)].push(node.clone()); } - // also, start the analysis from leaves + // start the analysis from leaves if egraph[node].is_leaf() { analysis_pending.insert(node.clone()); } diff --git a/src/extract/greedy_dag_1.rs b/src/extract/greedy_dag_1.rs index a328e43..ea4c76b 100644 --- a/src/extract/greedy_dag_1.rs +++ b/src/extract/greedy_dag_1.rs @@ -141,8 +141,6 @@ impl Extractor for FasterGreedyDagExtractor { costs.insert(class_id.clone(), cost_set); analysis_pending.extend(parents[class_id].iter().cloned()); } - } else { - analysis_pending.insert(node_id.clone()); } }