aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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();
}
}