{"draft":null,"from":129,"to":130,"files":[{"path":"src/engine/graph.ts","added":15,"removed":20,"diff":"--- a/src/engine/graph.ts\n+++ b/src/engine/graph.ts\n@@ -324,7 +324,9 @@\n \t\t\tthis.#resolversPages = storedLists<AtomId>(storage, \"resolvers\");\n \t\t\tthis.#togetherPages = storedLists<TogetherLink>(storage, \"together\");\n \t\t\tthis.#fileAtomPages = storedLists<AtomId>(storage, \"file-atoms\");\n-\t\t\tthis.#runStarts = storedMap(storage, \"run-starts\");\n+\t\t\tthis.#runStartPages = storedLists<number>(storage, \"run-starts\", (key) =>\n+\t\t\t\tJSON.stringify([\"number\", Number(key)]),\n+\t\t\t);\n \t\t\tthis.#relocationPages = storedLists<RelocationInfo>(storage, \"relocations\");\n \t\t\tthis.#relocatedToPages = storedLists<RelocationInfo>(storage, \"relocated-to\");\n \t\t\tthis.#relocatedToCodePages = storedLists<RelocationInfo>(storage, \"relocated-to-code\", (key) =>\n@@ -441,6 +443,7 @@\n \t#fileAtomPages: ReturnType<typeof storedLists<AtomId>> | undefined;\n \t/** First lines of runs (their n), by the node they were written after: a line's n, or -1 - a path's index. */\n \t#runStarts: StateMap<number, number | number[]> = new Map();\n+\t#runStartPages: ReturnType<typeof storedLists<number>> | undefined;\n \t/** 1 for the first line of a run whose atom deleted the line it hangs off: the run replaces it. */\n \t#replacing: NumberIndex = new Ints(true);\n \t#relocations: StateMap<LineId, RelocationInfo[]> = new Map();\n@@ -612,18 +615,20 @@\n \t}\n \n \t/** The lines (their n) written right after a node, as childrenOf, into `out`. */\n+\n \tchildrenN(code: number, out: number[]): void {\n+\t\tfor (const n of this.eachChildN(code)) out.push(n);\n+\t}\n+\t*eachChildN(code: number): IterableIterator<number> {\n \t\tif (\n \t\t\tcode >= 0 &&\n \t\t\tcode + 1 < this.#lineTotal &&\n \t\t\tthis.#lineAtom.at(code + 1) === this.#lineAtom.at(code) &&\n \t\t\tthis.#lineParent.at(code + 1) === code\n \t\t)\n-\t\t\tout.push(code + 1);\n-\t\tconst starts = this.#runStarts.get(code);\n-\t\tif (starts === undefined) return;\n-\t\tif (Array.isArray(starts)) out.push(...starts);\n-\t\telse out.push(starts);\n+\t\t\tyield code + 1;\n+\t\tif (this.#runStartPages) yield* this.#runStartPages.values(String(code));\n+\t\telse yield* listOf(this.#runStarts.get(code));\n \t}\n \n \treplacesN(n: number): boolean {\n@@ -770,21 +775,10 @@\n \t}\n \n \t/** Lines written right after a node (not counting moves), in seq order. */\n+\n \tchildrenOf(node: NodeId): LineId[] {\n-\t\tconst out: LineId[] = [];\n \t\tconst code = this.#nodeCode(node);\n-\t\tif (code === undefined) return out;\n-\t\t// The next line of the same run hangs off this one.\n-\t\tif (\n-\t\t\tcode >= 0 &&\n-\t\t\tcode + 1 < this.#lineTotal &&\n-\t\t\tthis.#lineAtom.at(code + 1) === this.#lineAtom.at(code) &&\n-\t\t\tthis.#lineParent.at(code + 1) === code\n-\t\t) {\n-\t\t\tout.push(this.#lineName(code + 1));\n-\t\t}\n-\t\tfor (const n of listOf(this.#runStarts.get(code))) out.push(this.#lineName(n));\n-\t\treturn out;\n+\t\treturn code === undefined ? [] : [...this.eachChildN(code)].map((n) => this.#lineName(n));\n \t}\n \n \t/** Whether a line starts a run whose atom deleted the line it hangs off. */\n@@ -1007,7 +1001,8 @@\n \t\t\tconst file = this.#pathOf(run.file);\n \t\t\tlet parent = isStartNode(run.parent) ? -1 - file : this.#lineN(run.parent);\n \t\t\tconst first = this.#lineTotal;\n-\t\t\tpushOne(this.#runStarts, parent, first);\n+\t\t\tif (this.#runStartPages) this.#runStartPages.append(String(parent), first);\n+\t\t\telse pushOne(this.#runStarts, parent, first);\n \t\t\tfor (let i = 0; i < run.lines.length; i++) {\n \t\t\t\tconst n = this.#lineTotal;\n \t\t\t\tthis.#lineAtom.push(seq);"}],"unmatched":[]}