Skip to content

Commit

Permalink
remove redundant changedAtoms set
Browse files Browse the repository at this point in the history
  • Loading branch information
dmaskasky committed Jan 6, 2025
1 parent 7a66fd0 commit c6e4d81
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/vanilla/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -554,12 +554,11 @@ const buildStore = (...storeArgs: StoreArgs): Store => {

// Step 2: use the topSortedReversed atom list to recompute all affected atoms
// Track what's changed, so that we can short circuit when possible
const changedAtoms = new Set<AnyAtom>(batch.D.keys())
for (let i = topSortedReversed.length - 1; i >= 0; --i) {
const [a, aState, prevEpochNumber] = topSortedReversed[i]!
let hasChangedDeps = false
for (const dep of aState.d.keys()) {
if (dep !== a && changedAtoms.has(dep)) {
if (dep !== a && batch.D.has(dep)) {
hasChangedDeps = true
break
}
Expand All @@ -569,7 +568,6 @@ const buildStore = (...storeArgs: StoreArgs): Store => {
mountDependencies(batch, a, aState)
if (prevEpochNumber !== aState.n) {
registerBatchAtom(batch, a, aState)
changedAtoms.add(a)
}
}
delete aState.x
Expand Down

0 comments on commit c6e4d81

Please sign in to comment.