aboutsummaryrefslogtreecommitdiff
path: root/incria
diff options
context:
space:
mode:
authortcmal <tcmal>2023-06-04 20:16:11 +0000
committerAria <me@aria.rip>2023-10-01 17:31:29 +0100
commitf12f006e2097c10e9d6171f4cf2996700a9f0e60 (patch)
tree5b0603616b465446201db540562f182448f2bb9f /incria
parent3582e43188cfa6e841c3bbd5f1613de59c327632 (diff)
list dependents rather than dependencies in dependency graph
Diffstat (limited to 'incria')
-rw-r--r--incria/examples/spreadsheet.rs2
-rw-r--r--incria/src/deps.rs20
2 files changed, 10 insertions, 12 deletions
diff --git a/incria/examples/spreadsheet.rs b/incria/examples/spreadsheet.rs
index 5c377e3..92bb506 100644
--- a/incria/examples/spreadsheet.rs
+++ b/incria/examples/spreadsheet.rs
@@ -33,7 +33,7 @@ fn cell_mapping() -> &'static CellMapping {
CELL_MAPPING.get_or_init(CellMapping::default)
}
-const N: usize = 20;
+const N: usize = 5;
#[tokio::main]
async fn main() {
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<NodeId>,
+ dependents: Vec<NodeId>,
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();
}
}