Skip to content

Commit

Permalink
Merge pull request #7 from oluwatimilehin/cleanup-items
Browse files Browse the repository at this point in the history
Cleanup items
  • Loading branch information
oluwatimilehin authored Jul 20, 2022
2 parents 2134e8d + a9cd76e commit 448d9a0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ This is still a work in progress, and some tasks I intend to work on in the near
- Implement [lord/anchors](https://lord.io/spreadsheets/) optimization - scroll to "anchors, a hybrid solution".
- Implement a `setUpdater()` function that allows you change the updater function for an `Anchor`.
- Cycle Detection.
- Add support for
an [Incremental.bind](https://ocaml.janestreet.com/ocaml-core/latest/doc/incremental/Incremental__/Incremental_intf/#bind)
equivalent.
Expand Down
8 changes: 4 additions & 4 deletions include/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ void Engine::set(AnchorPtr<T>& anchor, T val) {
anchor->set(val);

if (anchor->isNecessary()) {
for (const auto& parent : anchor->getDependants()) {
if (parent->isNecessary() && !d_recomputeSet.contains(parent)) {
d_recomputeHeap.push(parent);
d_recomputeSet.insert(parent);
for (const auto& dependant : anchor->getDependants()) {
if (dependant->isNecessary() && !d_recomputeSet.contains(dependant)) {
d_recomputeHeap.push(dependant);
d_recomputeSet.insert(dependant);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ void Engine::observeNode(

// Repeat the same for all its dependencies
for (auto& dep : current->getDependencies()) {
observeNode(dep, visited);
dep->addDependant(current);
observeNode(dep, visited);
}
}

Expand Down Expand Up @@ -73,4 +73,4 @@ void Engine::stabilize() {
d_recomputeSet.clear();
}

} // namespace anchors
} // namespace anchors
5 changes: 2 additions & 3 deletions test/engine.i.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ TEST_F(EngineFixture, IntegerArithmetic_observedValuesShouldBeUpToDate) {
AnchorPtr<int> anchorA(Anchors::create(2));
AnchorPtr<int> anchorB(Anchors::create(3));

auto sum = [](int a, int b) { return a + b; };

AnchorPtr<int> anchorC(Anchors::map2<int>(anchorA, anchorB, sum));
AnchorPtr<int> anchorC(Anchors::map2<int>(
anchorA, anchorB, [](int a, int b) { return a + b; }));

d_engine.observe(anchorC);

Expand Down

0 comments on commit 448d9a0

Please sign in to comment.