{"draft":null,"from":122,"to":123,"files":[{"path":"src/engine/view.ts","added":21,"removed":10,"diff":"--- a/src/engine/view.ts\n+++ b/src/engine/view.ts\n@@ -104,7 +104,8 @@\n \t/** 1 for each atom (by seq) in the set. */\n \t#in: Uint8Array;\n \t/** Atoms in the set that move lines. */\n-\t#movers: AtomId[];\n+\t#movers: AtomId[] | undefined;\n+\t#hasMoves = false;\n \t/** Each moved line's relocation that counts in this set; built on first use. */\n \t#relocs: Map<LineId, RelocationInfo> | undefined;\n \t/** The same, by n, with the new parent's code. */\n@@ -129,9 +130,14 @@\n \t\t\t\t\t\tthrow new EngineError(\"not-closed\", `set is not closed: ${id} depends on ${dependency}`);\n \t\t\t\t}\n \t\t\t}\n-\t\t\tthis.#movers = graph.movers().filter((id) => set.has(id));\n-\t\t\tthis.#relocs = this.#movers.length === 0 ? new Map() : undefined;\n-\t\t\tthis.#relocsN = this.#movers.length === 0 ? new Map() : undefined;\n+\t\t\tfor (const id of graph.movers()) {\n+\t\t\t\tif (set.has(id)) {\n+\t\t\t\t\tthis.#hasMoves = true;\n+\t\t\t\t\tbreak;\n+\t\t\t\t}\n+\t\t\t}\n+\t\t\tthis.#relocs = this.#hasMoves ? undefined : new Map();\n+\t\t\tthis.#relocsN = this.#hasMoves ? undefined : new Map();\n \t\t\treturn;\n \t\t}\n \t\tconst inSet = new Uint8Array(graph.size);\n@@ -152,6 +158,7 @@\n \t\tthis.graph = graph;\n \t\tthis.#in = inSet;\n \t\tthis.#movers = graph.movers().filter((id) => inSet[graph.atom(id).seq] === 1);\n+\t\tthis.#hasMoves = this.#movers.length > 0;\n \t\tthis.#relocs = this.#movers.length === 0 ? new Map() : undefined;\n \t\tthis.#relocsN = this.#movers.length === 0 ? new Map() : undefined;\n \t}\n@@ -198,7 +205,7 @@\n \t\t\treturn best;\n \t\t};\n \t\tconst relocs = new Map<LineId, RelocationInfo>();\n-\t\tfor (const id of this.#movers) {\n+\t\tfor (const id of this.#eachMover()) {\n \t\t\tfor (const m of graph.atom(id).moves!) {\n \t\t\t\tif (!relocs.has(m.line)) relocs.set(m.line, pick(m.line)!);\n \t\t\t}\n@@ -252,7 +259,7 @@\n \n \t/** The node a line hangs off in this set: where it was written, or where a move put it. */\n \tparentOf(line: LineId): NodeId {\n-\t\tconst r = this.#movers.length === 0 ? undefined : this.#relocations().get(line);\n+\t\tconst r = this.#hasMoves ? this.#relocations().get(line) : undefined;\n \t\tif (r) return r.parent;\n \t\tconst parent = this.graph.lineParent(line);\n \t\tif (parent === undefined) throw new EngineError(\"unknown-line\", `no line ${line}`);\n@@ -261,8 +268,12 @@\n \n \t/** Whether any atom in the set moves lines. */\n \thasMoves(): boolean {\n-\t\treturn this.#movers.length > 0;\n+\t\treturn this.#hasMoves;\n \t}\n+\t*#eachMover(): IterableIterator<AtomId> {\n+\t\tif (this.#movers) yield* this.#movers;\n+\t\telse for (const id of this.graph.movers()) if (this.#stable!.has(id)) yield id;\n+\t}\n \n \t/** The file a line is in, in this set: the one its chain of parents reaches. */\n \tfileOf(line: LineId): string {\n@@ -273,7 +284,7 @@\n \n \t#fileOfN(n: number): string {\n \t\tconst graph = this.graph;\n-\t\tif (this.#movers.length === 0) return graph.writtenIn(n);\n+\t\tif (!this.#hasMoves) return graph.writtenIn(n);\n \t\tconst relocs = this.#relocationsN();\n \t\tconst path: number[] = [];\n \t\tlet cur = n;\n@@ -295,7 +306,7 @@\n \t/** The lines hanging off a node in this set, in layout order. */\n \t#children(code: number): Child[] {\n \t\tconst graph = this.graph;\n-\t\tconst relocs = this.#movers.length === 0 ? undefined : this.#relocationsN();\n+\t\tconst relocs = this.#hasMoves ? this.#relocationsN() : undefined;\n \t\tconst ns: number[] = [];\n \t\tgraph.childrenN(code, ns);\n \t\tconst out: Child[] = [];\n@@ -517,7 +528,7 @@\n \tweight(): number {\n \t\tlet n = this.#in.byteLength;\n \t\tn += 2 * ARRAY_HEADER_BYTES + this.#membershipSeq.byteLength + this.#membershipValue.byteLength;\n-\t\tn += ARRAY_HEADER_BYTES + REFERENCE_BYTES * this.#movers.length;\n+\t\tif (this.#movers) n += ARRAY_HEADER_BYTES + REFERENCE_BYTES * this.#movers.length;\n \t\tn += MAP_HEADER_BYTES; // #files exists from construction.\n \t\tn += MAP_HEADER_BYTES; // #fileOf exists from construction.\n \t\tif (this.#stable) n += this.#stable.retainedBytes;"}],"unmatched":[]}