Deduplicate subject updates. Fixes #3.

This commit is contained in:
Tony Garnock-Jones 2023-12-18 10:32:37 +13:00
parent 3617582d37
commit 4d0cc4b2f7
1 changed files with 6 additions and 2 deletions

View File

@ -95,10 +95,14 @@ export class Graph<SubjectId, ObjectId> implements ObservingGraph<ObjectId> {
if (workSet.size === 0) break;
const updatedSubjects = new FlexSet(this.subjectIdCanonicalizer);
workSet.forEach(objectId => {
this.observersOf(objectId).forEach((subjectId: SubjectId) => {
this.forgetSubject(subjectId);
this.withSubject(subjectId, () => repairNode(subjectId));
if (!updatedSubjects.has(subjectId)) {
updatedSubjects.add(subjectId);
this.forgetSubject(subjectId);
this.withSubject(subjectId, () => repairNode(subjectId));
}
});
});
}