{"draft":null,"from":124,"to":125,"files":[{"path":"src/engine/view.ts","added":11,"removed":2,"diff":"--- a/src/engine/view.ts\n+++ b/src/engine/view.ts\n@@ -83,6 +83,7 @@\n const MAP_ENTRY_BYTES = 40;\n const SET_ENTRY_BYTES = 32;\n const REFERENCE_BYTES = 8;\n+const FILE_LOCATION_MEMO_ENTRIES = 256;\n \n /**\n  * The projection of a closed set. Construct once, then ask for files, lines\n@@ -110,6 +111,7 @@\n \t#relocs: Map<LineId, RelocationInfo> | undefined;\n \t/** The same, by n, with the new parent's code. */\n \t#relocsN: Map<number, { readonly r: RelocationInfo; readonly parent: number }> | undefined;\n+\t/** Bounded memo: ancestry can span the entire history even for one visible line. */\n \t#fileOf = new Map<number, string>();\n \t/** The latest records asked for: one file's lines, one file's sequence, one file's text. */\n \t#linesCache: { path: string; lines: readonly VisibleLine[] } | undefined;\n@@ -286,7 +288,10 @@\n \t\tconst graph = this.graph;\n \t\tif (!this.#hasMoves) return graph.writtenIn(n);\n \t\tconst relocs = this.#relocationsN();\n+\t\t// Keep only a fixed tail of the walk for path compression. The selected\n+\t\t// relocation graph is acyclic, so traversal needs no history-sized stack.\n \t\tconst path: number[] = [];\n+\t\tlet visited = 0;\n \t\tlet cur = n;\n \t\tlet file: string | undefined;\n \t\twhile (file === undefined) {\n@@ -294,12 +299,16 @@\n \t\t\telse {\n \t\t\t\tfile = this.#fileOf.get(cur);\n \t\t\t\tif (file === undefined) {\n-\t\t\t\t\tpath.push(cur);\n+\t\t\t\t\tpath[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\tfor (const l of path) this.#fileOf.set(l, file);\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+\t\t\tthis.#fileOf.set(l, file);\n+\t\t}\n \t\treturn file;\n \t}\n "}],"unmatched":[]}