# HG changeset patch # User drewp@bigasterisk.com # Date 2023-05-29 20:24:01 # Node ID 9ca3d356b9509d9dbb4b59e2f84e419619390cf6 # Parent 698da65519a3b9919a0c6483bb285f866950a406 attempted rewrite of rerunInners diff --git a/light9/web/AutoDependencies.ts b/light9/web/AutoDependencies.ts --- a/light9/web/AutoDependencies.ts +++ b/light9/web/AutoDependencies.ts @@ -95,40 +95,31 @@ export class AutoDependencies { prn(this.handlers, ""); } - _handlerIsAffected(child: Handler, patchSubjs: Set) { - if (patchSubjs === null) { - return true; - } - if (!child.patterns.length) { - return false; - } - - for (let stmt of Array.from(child.patterns)) { - if (stmt.subject === null) { - // wildcard on subject - return true; - } - if (patchSubjs.has(stmt.subject.value)) { + _handlerIsAffected(child: Handler, patch: Patch): boolean { + // it should be correct but slow to always return true here + for (let pat of child.patterns) { + if (patch.matches(pat)) { return true; } } - return false; } graphChanged(patch: Patch) { // SyncedGraph is telling us this patch just got applied to the graph. - const subjs = allPatchSubjs(patch); var rerunInners = (cur: Handler) => { const toRun = cur.innerHandlers.slice(); for (let child of Array.from(toRun)) { - //match = @_handlerIsAffected(child, subjs) - //continue if not match - //log('match', child.label, match) - //child.innerHandlers = [] # let all children get called again - this._rerunHandler(child, patch); - rerunInners(child); + const match = this._handlerIsAffected(child, patch); + + if (match) { + log("match", child.label, match); + child.innerHandlers = []; // let all children get called again + this._rerunHandler(child, patch); + } else { + rerunInners(child); + } } }; rerunInners(this.handlers);