{"draft":null,"from":206,"to":207,"files":[{"path":"src/engine/view.ts","added":36,"removed":3,"diff":"--- a/src/engine/view.ts\n+++ b/src/engine/view.ts\n@@ -47,7 +47,7 @@\n }\n \n /** Structural read boundary shared by historical and transaction-bound projections. */\n-export type ReadView = Omit<Pick<View, keyof View>, \"sameText\"> & {\n+export type ReadView = Omit<Pick<View, keyof View>, \"sameText\" | \"visibleCount\" | \"shareMoves\"> & {\n \tsameText(path: string, other: ReadView): boolean;\n };\n \n@@ -100,6 +100,8 @@\n export const MOVED_LINES_KEPT = 20_000;\n class TooManyMoves extends Error {}\n const NO_LINES: readonly number[] = Object.freeze([]);\n+/** Lines whose place views sharing moves remember, at most: about 40 bytes each. */\n+const SHARED_FILE_MEMO = 200_000;\n \n /**\n  * The projection of a closed set. Construct once, then ask for files, lines\n@@ -274,6 +276,25 @@\n \t\treturn relocs;\n \t}\n \n+\t/** Where lines sit, shared with views that took this one's moves (shareMoves): unbounded up to SHARED_FILE_MEMO. */\n+\t#fileOfShared: Map<number, string> | undefined;\n+\n+\t/**\n+\t * Take another view's resolved moves (abso Capacity). Only for a set that differs from that view's by atoms that\n+\t * move nothing, drop nothing and change no closure: its moves resolve the same, and every line it shares with that\n+\t * view sits where it sat there.\n+\t */\n+\tshareMoves(from: View): void {\n+\t\tif (from.graph !== this.graph || from.#hasMoves !== this.#hasMoves || !this.#hasMoves) return;\n+\t\tif (from.#scratchMoves()) return;\n+\t\tthis.#relocs = from.#relocations();\n+\t\tthis.#relocsN = from.#relocationsN();\n+\t\tthis.#movesOnDisk = false;\n+\t\tthis.#movedFrom = from.#movedInFrom();\n+\t\tfrom.#fileOfShared ??= new Map();\n+\t\tthis.#fileOfShared = from.#fileOfShared;\n+\t}\n+\n \t/** Whether moves are resolved on disk for each layout: only a stored graph's view with more than MOVED_LINES_KEPT. */\n \t#scratchMoves(): boolean {\n \t\tif (!this.#hasMoves || !this.graph.hasOrderedChildren) return false;\n@@ -349,13 +370,20 @@\n \t\twhile (file === undefined) {\n \t\t\tif (cur < 0) file = graph.nodeOf(cur).slice(1);\n \t\t\telse {\n-\t\t\t\tfile = this.#fileOf.get(cur);\n+\t\t\t\tfile = (this.#fileOfShared ?? this.#fileOf).get(cur);\n \t\t\t\tif (file === undefined) {\n-\t\t\t\t\tpath[visited++ % FILE_LOCATION_MEMO_ENTRIES] = cur;\n+\t\t\t\t\tif (this.#fileOfShared) path.push(cur);\n+\t\t\t\t\telse path[visited++ % FILE_LOCATION_MEMO_ENTRIES] = cur;\n \t\t\t\t\tcur = relocs.get(cur)?.parent ?? graph.parentCodeOf(cur);\n \t\t\t\t}\n \t\t\t}\n \t\t}\n+\t\tconst shared = this.#fileOfShared;\n+\t\tif (shared) {\n+\t\t\tif (shared.size > SHARED_FILE_MEMO) shared.clear();\n+\t\t\tfor (const l of path) shared.set(l, file);\n+\t\t\treturn file;\n+\t\t}\n \t\tfor (const l of path) {\n \t\t\tif (!this.#fileOf.has(l) && this.#fileOf.size >= FILE_LOCATION_MEMO_ENTRIES)\n \t\t\t\tthis.#fileOf.delete(this.#fileOf.keys().next().value!);\n@@ -668,6 +696,11 @@\n \t\treturn [...this.#known];\n \t}\n \n+\t/** How many visible lines a file has. */\n+\tvisibleCount(path: string): number {\n+\t\treturn this.#file(path).vis.length;\n+\t}\n+\n \t/** Whether the file exists in this projection (has a visible line). */\n \thasFile(path: string): boolean {\n \t\tconst attrs = this.attrs(path);"}],"unmatched":[]}