{"draft":null,"from":118,"to":119,"files":[{"path":"src/engine/graph.ts","added":23,"removed":4,"diff":"--- a/src/engine/graph.ts\n+++ b/src/engine/graph.ts\n@@ -15,8 +15,15 @@\n \tseqOf,\n \tstartNode,\n } from \"./keys.ts\";\n-import { type GraphStateStorage, type StateMap, storedArray, storedMap, storedNumbers } from \"./state-source.ts\";\n import {\n+\ttype GraphStateStorage,\n+\ttype StateMap,\n+\tstoredArray,\n+\tstoredLists,\n+\tstoredMap,\n+\tstoredNumbers,\n+} from \"./state-source.ts\";\n+import {\n \tATTR_NAMES,\n \ttype Atom,\n \ttype AtomId,\n@@ -314,7 +321,7 @@\n \t\t\tthis.#dependents = storedMap(storage, \"dependents\");\n \t\t\tthis.#resolvers = storedMap(storage, \"resolvers\");\n \t\t\tthis.#together = storedMap(storage, \"together\");\n-\t\t\tthis.#fileAtoms = storedMap(storage, \"file-atoms\");\n+\t\t\tthis.#fileAtomPages = storedLists<AtomId>(storage, \"file-atoms\");\n \t\t\tthis.#runStarts = storedMap(storage, \"run-starts\");\n \t\t\tthis.#relocations = storedMap(storage, \"relocations\");\n \t\t\tthis.#relocatedTo = storedMap(storage, \"relocated-to\");\n@@ -420,6 +427,7 @@\n \t#resolvers: StateMap<AtomId, AtomId | AtomId[]> = new Map();\n \t#together: StateMap<AtomId, TogetherLink[]> = new Map();\n \t#fileAtoms: StateMap<string, AtomId[]> = new Map();\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/** 1 for the first line of a run whose atom deleted the line it hangs off: the run replaces it. */\n@@ -702,12 +710,20 @@\n \n \t/** Every atom that inserts or deletes a line of the file, in seq order. */\n \tatomsIn(file: string): readonly AtomId[] {\n+\t\tif (this.#fileAtomPages) return [...this.#fileAtomPages.values(file)];\n \t\treturn this.#fileAtoms.get(file) ?? EMPTY;\n \t}\n+\t*eachAtomIn(file: string): IterableIterator<AtomId> {\n+\t\tif (this.#fileAtomPages) yield* this.#fileAtomPages.values(file);\n+\t\telse yield* this.#fileAtoms.get(file) ?? EMPTY;\n+\t}\n+\thasAtomsIn(file: string): boolean {\n+\t\treturn this.#fileAtomPages ? this.#fileAtomPages.length(file) > 0 : this.#fileAtoms.has(file);\n+\t}\n \n \t/** Unique historical file paths, streamed without collecting their names. */\n \t*knownFiles(): IterableIterator<string> {\n-\t\tyield* this.#fileAtoms.keys();\n+\t\tyield* this.#fileAtomPages ? this.#fileAtomPages.keys() : this.#fileAtoms.keys();\n \t}\n \n \t/**\n@@ -981,7 +997,10 @@\n \t\t\tfiles.add(isStartNode(m.parent) ? m.parent.slice(1) : this.lineFile(m.parent)!);\n \t\t}\n \t\tthis.#atomFiles.push(Object.freeze([...files].sort()));\n-\t\tfor (const file of files) pushIndex(this.#fileAtoms, file, frozen.id);\n+\t\tfor (const file of files) {\n+\t\t\tif (this.#fileAtomPages) this.#fileAtomPages.append(file, frozen.id);\n+\t\t\telse pushIndex(this.#fileAtoms, file, frozen.id);\n+\t\t}\n \t\tfor (const r of frozen.reasons) {\n \t\t\tif (r.kind !== \"together\" || r.to === frozen.id) continue;\n \t\t\tpushIndex(this.#together, frozen.id, { other: r.to, text: r.text, from: frozen.id });"}],"unmatched":[]}