From f12f006e2097c10e9d6171f4cf2996700a9f0e60 Mon Sep 17 00:00:00 2001 From: tcmal Date: Sun, 4 Jun 2023 20:16:11 +0000 Subject: list dependents rather than dependencies in dependency graph --- incria/src/deps.rs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'incria/src') diff --git a/incria/src/deps.rs b/incria/src/deps.rs index acc39f1..f94d3ff 100644 --- a/incria/src/deps.rs +++ b/incria/src/deps.rs @@ -41,10 +41,10 @@ impl DepTracker { self.deps .lock() .unwrap() - .entry(NODE_ID.get()) - .and_modify(|v| v.deps.push(dep)) + .entry(dep) + .and_modify(|v| v.dependents.push(NODE_ID.get())) .or_insert(NodeInfo { - deps: vec![dep], + dependents: vec![NODE_ID.get()], dirty: false, }); } @@ -72,10 +72,8 @@ impl DepTracker { } node.dirty = true; - for (dependent, dependent_info) in lock.iter() { - if dependent_info.deps.contains(&node_id) { - frontier.push_back(*dependent); - } + for dependent in node.dependents.iter() { + frontier.push_back(*dependent); } } } @@ -99,13 +97,13 @@ impl DepTracker { }; node.dirty = false; - node.deps = vec![]; + node.dependents = vec![]; } } /// Info about a single dependency node struct NodeInfo { - deps: Vec, + dependents: Vec, dirty: bool, } @@ -162,8 +160,8 @@ pub fn dep_graphviz() -> String { } else if info.dirty { writeln!(&mut out, "\t{} [style=filled,color=lightgrey]", id).unwrap(); } - for dep in info.deps.iter() { - writeln!(&mut out, "\t{} -> {}", id, dep).unwrap(); + for dep in info.dependents.iter() { + writeln!(&mut out, "\t{} -> {}", dep, id).unwrap(); } } -- cgit v1.2.3