Versions 214 to 215
Lines 95–100 at 215 (were 95–101 at 214)
98−const FILE_LOCATION_MEMO_ENTRIES = 256;
10099 * Moved lines a view resolves once and keeps (abso Capacity): a stored graph otherwise resolved every move again on
101100 * disk for each file it laid out. Game's whole history has 290; past this many, the view goes back to that.
Lines 102–187 at 215 (were 103–112 at 214)
106−/** Lines whose place views sharing moves remember, at most: about 40 bytes each. */
107−const SHARED_FILE_MEMO = 200_000;
108107
114+
116+ * A graph's moves, whatever the set (abso Capacity): each mover's moved lines, each moved line's relocations in seq
117+ * order, and for any node the nearest node at or above it, by where lines were written, that a move ever relocated,
118+ * or its file's start. Worked out once per graph and extended as it grows. A view's moves then resolve over the moved
119+ * lines alone: before, every view walked each moved line's file up to its start, a read per line.
129+
133+
157+
158+ /** The nearest node at or above this one, by where lines were written, that a move ever relocated; or its file's start. */
176+
183+
Lines 211–216 at 215 (were 136–143 at 214)
137212 /** Whether this view's moves are too many to keep, so they're resolved on disk per layout; undefined until asked. */
139− /** Bounded memo: ancestry can span the entire history even for one visible line. */
140− #fileOf = new Map<number, string>();
Lines 296–341 at 215 (were 223–256 at 214)
226300 const stronger = (a: RelocationInfo, b: RelocationInfo): boolean => graph.comparePriority(a.atom, b.atom) > 0;
227− // Persistent reads decode new objects. Cycle suppression must identify the
228− // logical move, not one particular decoded JavaScript object.
231− const pick = (line: LineId): RelocationInfo | undefined => {
232− let best: RelocationInfo | undefined;
233− for (const r of graph.eachRelocationOf(line)) {
234− if (this.#has(graph.atom(r.atom).seq) && !ignored.has(identity(r)) && (!best || stronger(r, best))) best = r;
306+ if (this.#has(seqOf(e.r.atom)) && !ignored.has(identity(e.r)) && (!best || stronger(e.r, best.r))) best = e;
238− const relocs = new Map<LineId, RelocationInfo>();
239− for (const id of this.#eachMover()) {
240− for (const m of graph.atom(id).moves!) {
241− if (!relocs.has(m.line)) relocs.set(m.line, pick(m.line)!);
310+ // By the moved line's number, in the order its movers come (seq order, then each mover's moves).
245− const parentOf = (line: LineId): NodeId => relocs.get(line)?.parent ?? graph.lineParent(line)!;
246− const reaches = new Set<LineId>();
319+ // From a node, the next node that matters for loops: a line moved in this set, or a file's start.
329+ // Two moves made apart can loop lines into each other, so no start node reaches them; then the oldest
330+ // relocation on the loop is ignored, and the next newest of that line counts, until none loop.
249− const path: LineId[] = [];
250− const onPath = new Map<LineId, number>();
251− let cur: NodeId = line;
253− while (!isStartNode(cur) && !reaches.has(cur)) {
Lines 343–370 at 215 (were 258–287 at 214)
261− cur = parentOf(cur);
267− let weakest: RelocationInfo | undefined;
269− const r = relocs.get(l);
270− if (r && (!weakest || stronger(weakest, r))) weakest = r;
272− ignored.add(identity(weakest!));
273− const next = pick(weakest!.line);
274− if (next) relocs.set(weakest!.line, next);
275− else relocs.delete(weakest!.line);
278− this.#relocs = relocs;
279− return relocs;
281367
282− /** Where lines sit, shared with views that took this one's moves (shareMoves): unbounded up to SHARED_FILE_MEMO. */
283− #fileOfShared: Map<number, string> | undefined;
284−
286369 * Take another view's resolved moves (abso Capacity), when both sets hold the very same atoms that move lines: the
287370 * moves then resolve the same, and every line sits where it sits there. Checked here, so any caller may ask.
Lines 380–385 at 215 (were 297–304 at 214)
300− from.#fileOfShared ??= new Map();
301− this.#fileOfShared = from.#fileOfShared;
303384
304385 /** Whether moves are resolved on disk for each layout: only a stored graph's view with more than MOVED_LINES_KEPT. */
Lines 447–467 at 215 (were 366–401 at 214)
452+
453+ /** The file a node sits in, in this set: up by where lines were written, through the moves that count here. */
370− // Keep only a fixed tail of the walk for path compression. The selected
371− // relocation graph is acyclic, so traversal needs no history-sized stack.
372− const path: number[] = [];
373− let visited = 0;
374− let cur = n;
375− let file: string | undefined;
376− while (file === undefined) {
377− if (cur < 0) file = graph.nodeOf(cur).slice(1);
378− else {
379− file = (this.#fileOfShared ?? this.#fileOf).get(cur);
380− if (file === undefined) {
381− if (this.#fileOfShared) path.push(cur);
382− else path[visited++ % FILE_LOCATION_MEMO_ENTRIES] = cur;
383− cur = relocs.get(cur)?.parent ?? graph.parentCodeOf(cur);
384− }
385− }
387− const shared = this.#fileOfShared;
388− if (shared) {
389− if (shared.size > SHARED_FILE_MEMO) shared.clear();
390− for (const l of path) shared.set(l, file);
391− return file;
392− }
393− for (const l of path) {
394− if (!this.#fileOf.has(l) && this.#fileOf.size >= FILE_LOCATION_MEMO_ENTRIES)
395− this.#fileOf.delete(this.#fileOf.keys().next().value!);
396− this.#fileOf.set(l, file);
397− }
398− return file;
400466
Lines 573–579 at 215 (were 507–531 at 214)
510− // Where each node sits, walked once for the whole view: through the moves, up to a file's start.
511− const memo = new Map<number, string>();
512− const fileOf = (code: number): string => {
513− const walked: number[] = [];
514− let cur = code;
515− let file: string | undefined;
516− while (file === undefined) {
517− if (cur < 0) file = graph.nodeOf(cur).slice(1);
518− else {
519− file = memo.get(cur);
520− if (file === undefined) {
521− walked.push(cur);
522− cur = relocs.get(cur)?.parent ?? graph.parentCodeOf(cur);
523− }
524− }
525− }
526− for (const n of walked) memo.set(n, file);
527− return file;
528− };
Lines 957–967 at 215 (were 909–921 at 214)
909957 n += 2 * ARRAY_HEADER_BYTES + this.#membershipSeq.byteLength + this.#membershipValue.byteLength;
912− n += MAP_HEADER_BYTES; // #fileOf exists from construction.
917964 if (this.#relocsN) n += MAP_HEADER_BYTES + (MAP_ENTRY_BYTES + OBJECT_BYTES) * this.#relocsN.size;
918− n += MAP_ENTRY_BYTES * this.#fileOf.size;
- MCP
- compare on this site's /mcp
- CLI
- abso diff 214 215 src/engine/view.ts --json
- JSON
- /christopher/abso-core/compare/214..215?file=src%2Fengine%2Fview.ts&format=json