# HG changeset patch # User drewp@bigasterisk.com # Date 1685391841 25200 # Node ID 9ca3d356b9509d9dbb4b59e2f84e419619390cf6 # Parent 698da65519a3b9919a0c6483bb285f866950a406 attempted rewrite of rerunInners diff -r 698da65519a3 -r 9ca3d356b950 light9/web/AutoDependencies.ts --- a/light9/web/AutoDependencies.ts Mon May 29 13:23:16 2023 -0700 +++ b/light9/web/AutoDependencies.ts Mon May 29 13:24:01 2023 -0700 @@ -95,40 +95,31 @@ 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);