{"draft":null,"from":119,"to":120,"files":[{"path":"src/engine/graph.ts","added":39,"removed":9,"diff":"--- a/src/engine/graph.ts\n+++ b/src/engine/graph.ts\n@@ -315,9 +315,9 @@\n \t\t\tthis.#lineText = storedArray(storage, \"line-text\");\n \t\t\tthis.#pathIndex = storedMap(storage, \"path-index\");\n \t\t\tthis.#moreDeleters = storedMap(storage, \"more-deleters\");\n-\t\t\tthis.#writers = storedMap(storage, \"writers\");\n-\t\t\tthis.#readers = storedMap(storage, \"readers\");\n-\t\t\tthis.#holders = storedMap(storage, \"holders\");\n+\t\t\tthis.#writersPages = storedLists<AtomId>(storage, \"writers\", (key) => key);\n+\t\t\tthis.#readersPages = storedLists<AtomId>(storage, \"readers\", (key) => key);\n+\t\t\tthis.#holdersPages = storedLists<AtomId>(storage, \"holders\", (key) => key);\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@@ -421,8 +421,11 @@\n \t#deleter: NumberIndex = new Ints();\n \t#moreDeleters: StateMap<number, number[]> = new Map();\n \t#writers: StateMap<Key | number, AtomId | AtomId[]> = new Map();\n+\t#writersPages: ReturnType<typeof storedLists<AtomId>> | undefined;\n \t#readers: StateMap<Key | number, AtomId | AtomId[]> = new Map();\n+\t#readersPages: ReturnType<typeof storedLists<AtomId>> | undefined;\n \t#holders: StateMap<Key | number, AtomId | AtomId[]> = new Map();\n+\t#holdersPages: ReturnType<typeof storedLists<AtomId>> | undefined;\n \t#dependents: StateMap<AtomId, AtomId | AtomId[]> = new Map();\n \t#resolvers: StateMap<AtomId, AtomId | AtomId[]> = new Map();\n \t#together: StateMap<AtomId, TogetherLink[]> = new Map();\n@@ -695,18 +698,33 @@\n \t}\n \n \twritersOf(key: Key): readonly AtomId[] {\n-\t\treturn listOf(this.#writers.get(this.#code(key)));\n+\t\treturn [...this.eachWriterOf(key)];\n \t}\n+\t*eachWriterOf(key: Key): IterableIterator<AtomId> {\n+\t\tconst code = this.#code(key);\n+\t\tif (this.#writersPages) yield* this.#writersPages.values(JSON.stringify([typeof code, code]));\n+\t\telse yield* listOf(this.#writers.get(code));\n+\t}\n \n \t/** Atoms whose implicit reads include the key. */\n \treadersOf(key: Key): readonly AtomId[] {\n-\t\treturn listOf(this.#readers.get(this.#code(key)));\n+\t\treturn [...this.eachReaderOf(key)];\n \t}\n+\t*eachReaderOf(key: Key): IterableIterator<AtomId> {\n+\t\tconst code = this.#code(key);\n+\t\tif (this.#readersPages) yield* this.#readersPages.values(JSON.stringify([typeof code, code]));\n+\t\telse yield* listOf(this.#readers.get(code));\n+\t}\n \n \t/** Atoms whose explicit holds include the key. */\n \tholdersOf(key: Key): readonly AtomId[] {\n-\t\treturn listOf(this.#holders.get(this.#code(key)));\n+\t\treturn [...this.eachHolderOf(key)];\n \t}\n+\t*eachHolderOf(key: Key): IterableIterator<AtomId> {\n+\t\tconst code = this.#code(key);\n+\t\tif (this.#holdersPages) yield* this.#holdersPages.values(JSON.stringify([typeof code, code]));\n+\t\telse yield* listOf(this.#holders.get(code));\n+\t}\n \n \t/** Every atom that inserts or deletes a line of the file, in seq order. */\n \tatomsIn(file: string): readonly AtomId[] {\n@@ -983,9 +1001,21 @@\n \t\t\tif (this.#deleter.at(n) < 0) this.#deleter.set(n, seq);\n \t\t\telse pushIndex(this.#moreDeleters, n, seq);\n \t\t}\n-\t\tfor (const key of new Set(atom.writes)) pushOne(this.#writers, this.#code(key), frozen.id);\n-\t\tfor (const key of new Set(atom.reads)) pushOne(this.#readers, this.#code(key), frozen.id);\n-\t\tfor (const key of new Set(atom.holds)) pushOne(this.#holders, this.#code(key), frozen.id);\n+\t\tfor (const key of new Set(atom.writes)) {\n+\t\t\tconst code = this.#code(key);\n+\t\t\tif (this.#writersPages) this.#writersPages.append(JSON.stringify([typeof code, code]), frozen.id);\n+\t\t\telse pushOne(this.#writers, code, frozen.id);\n+\t\t}\n+\t\tfor (const key of new Set(atom.reads)) {\n+\t\t\tconst code = this.#code(key);\n+\t\t\tif (this.#readersPages) this.#readersPages.append(JSON.stringify([typeof code, code]), frozen.id);\n+\t\t\telse pushOne(this.#readers, code, frozen.id);\n+\t\t}\n+\t\tfor (const key of new Set(atom.holds)) {\n+\t\t\tconst code = this.#code(key);\n+\t\t\tif (this.#holdersPages) this.#holdersPages.append(JSON.stringify([typeof code, code]), frozen.id);\n+\t\t\telse pushOne(this.#holders, code, frozen.id);\n+\t\t}\n \t\tfor (const d of deps) pushOne(this.#dependents, d, frozen.id);\n \t\tfor (const r of new Set(frozen.resolves)) pushOne(this.#resolvers, r, frozen.id);\n \t\tconst files = new Set<string>();"}],"unmatched":[]}