Lines 104–111 at 123 (were 104–110 at 122)
104104 /** 1 for each atom (by seq) in the set. */ 106106 /** Atoms in the set that move lines. */ 107− #movers: AtomId[];
107+ #movers: AtomId[] | undefined; 108109 /** Each moved line's relocation that counts in this set; built on first use. */ 109110 #relocs: Map<LineId, RelocationInfo> | undefined; 110111 /** The same, by n, with the new parent's code. */ Lines 130–143 at 123 (were 129–137 at 122)
129130 throw new EngineError("not-closed", `set is not closed: ${id} depends on ${dependency}`); 132− this.#movers = graph.movers().filter((id) => set.has(id));
133− this.#relocs = this.#movers.length === 0 ? new Map() : undefined;
134− this.#relocsN = this.#movers.length === 0 ? new Map() : undefined;
133+ for (const id of graph.movers()) { 135+ this.#hasMoves = true; 139+ this.#relocs = this.#hasMoves ? undefined : new Map(); 140+ this.#relocsN = this.#hasMoves ? undefined : new Map(); 137143 const inSet = new Uint8Array(graph.size); Lines 158–164 at 123 (were 152–157 at 122)
152158 this.graph = graph; 154160 this.#movers = graph.movers().filter((id) => inSet[graph.atom(id).seq] === 1); 161+ this.#hasMoves = this.#movers.length > 0; 155162 this.#relocs = this.#movers.length === 0 ? new Map() : undefined; 156163 this.#relocsN = this.#movers.length === 0 ? new Map() : undefined; Lines 205–211 at 123 (were 198–204 at 122)
200207 const relocs = new Map<LineId, RelocationInfo>(); 201− for (const id of this.#movers) {
208+ for (const id of this.#eachMover()) { 202209 for (const m of graph.atom(id).moves!) { 203210 if (!relocs.has(m.line)) relocs.set(m.line, pick(m.line)!); Lines 259–265 at 123 (were 252–258 at 122)
253260 /** The node a line hangs off in this set: where it was written, or where a move put it. */ 254261 parentOf(line: LineId): NodeId { 255− const r = this.#movers.length === 0 ? undefined : this.#relocations().get(line);
262+ const r = this.#hasMoves ? this.#relocations().get(line) : undefined; 256263 if (r) return r.parent; 257264 const parent = this.graph.lineParent(line); 258265 if (parent === undefined) throw new EngineError("unknown-line", `no line ${line}`); Lines 268–279 at 123 (were 261–268 at 122)
262269 /** Whether any atom in the set moves lines. */ 263270 hasMoves(): boolean { 264− return this.#movers.length > 0;
271+ return this.#hasMoves; 273+ *#eachMover(): IterableIterator<AtomId> { 274+ if (this.#movers) yield* this.#movers; 275+ else for (const id of this.graph.movers()) if (this.#stable!.has(id)) yield id; 267278 /** The file a line is in, in this set: the one its chain of parents reaches. */ 268279 fileOf(line: LineId): string { Lines 284–290 at 123 (were 273–279 at 122)
274285 #fileOfN(n: number): string { 275286 const graph = this.graph; 276− if (this.#movers.length === 0) return graph.writtenIn(n);
287+ if (!this.#hasMoves) return graph.writtenIn(n); 277288 const relocs = this.#relocationsN(); 278289 const path: number[] = []; Lines 306–312 at 123 (were 295–301 at 122)
295306 /** The lines hanging off a node in this set, in layout order. */ 296307 #children(code: number): Child[] { 297308 const graph = this.graph; 298− const relocs = this.#movers.length === 0 ? undefined : this.#relocationsN();
309+ const relocs = this.#hasMoves ? this.#relocationsN() : undefined; 299310 const ns: number[] = []; 300311 graph.childrenN(code, ns); 301312 const out: Child[] = []; Lines 528–534 at 123 (were 517–523 at 122)
517528 weight(): number { 518529 let n = this.#in.byteLength; 519530 n += 2 * ARRAY_HEADER_BYTES + this.#membershipSeq.byteLength + this.#membershipValue.byteLength; 520− n += ARRAY_HEADER_BYTES + REFERENCE_BYTES * this.#movers.length;
531+ if (this.#movers) n += ARRAY_HEADER_BYTES + REFERENCE_BYTES * this.#movers.length; 521532 n += MAP_HEADER_BYTES; // #files exists from construction. 522533 n += MAP_HEADER_BYTES; // #fileOf exists from construction. 523534 if (this.#stable) n += this.#stable.retainedBytes;