{"draft":null,"from":111,"to":318,"files":[{"path":"src/engine/conflicts.ts","added":18,"removed":28,"diff":"--- a/src/engine/conflicts.ts\n+++ b/src/engine/conflicts.ts\n@@ -126,22 +126,28 @@\n /** `a` has the lower seq. */\n function makeConflict(graph: Graph, set: AtomSet | undefined, a: Atom, b: Atom, keys: ConflictKey[]): Conflict {\n \tconst kind = keys.every((k) => k.relation === \"hold\") ? \"semantic\" : \"edit-edit\";\n-\tlet resolvedBy: AtomId[] = [];\n+\tconst resolvedBy: AtomId[] = [];\n \tif (set) {\n-\t\tconst fromA = graph.resolversOf(a.id).filter((r) => set.has(r));\n-\t\tconst fromB = new Set(graph.resolversOf(b.id));\n-\t\tresolvedBy = fromA.filter((r) => fromB.has(r)).sort((p, q) => graph.atom(p).seq - graph.atom(q).seq);\n+\t\t// Resolver indexes append in sequence order: intersect without copying either history.\n+\t\tconst left = graph.eachResolverOf(a.id);\n+\t\tconst right = graph.eachResolverOf(b.id);\n+\t\tlet p = left.next();\n+\t\tlet q = right.next();\n+\t\twhile (!p.done && !q.done) {\n+\t\t\tconst order = graph.atom(p.value).seq - graph.atom(q.value).seq;\n+\t\t\tif (order === 0 && set.has(p.value)) resolvedBy.push(p.value);\n+\t\t\tif (order <= 0) p = left.next();\n+\t\t\tif (order >= 0) q = right.next();\n+\t\t}\n \t}\n \treturn { atoms: [a.id, b.id], kind, keys, sides: [side(a), side(b)], resolvedBy };\n }\n \n /** Atoms in the set that claim (write, read or hold) a key. */\n-function claimersIn(graph: Graph, set: AtomSet, key: Key): AtomId[] {\n-\tconst out: AtomId[] = [];\n-\tfor (const list of [graph.writersOf(key), graph.readersOf(key), graph.holdersOf(key)]) {\n-\t\tfor (const id of list) if (set.has(id)) out.push(id);\n+function* claimersIn(graph: Graph, set: AtomSet, key: Key): IterableIterator<AtomId> {\n+\tfor (const list of [graph.eachWriterOf(key), graph.eachReaderOf(key), graph.eachHolderOf(key)]) {\n+\t\tfor (const id of list) if (set.has(id)) yield id;\n \t}\n-\treturn out;\n }\n \n const bySeq =\n@@ -201,23 +207,7 @@\n function visibleNeighbours(view: View, graph: Graph, line: LineId): LineId[] {\n \tconst info = graph.line(line);\n \tif (!info) return [];\n-\tconst sequence = view.sequence(info.file);\n-\tconst at = view.sequenceIndex(info.file, line);\n-\tif (at < 0) return [];\n-\tconst out: LineId[] = [];\n-\tfor (let i = at - 1; i >= 0; i--) {\n-\t\tif (sequence[i]!.visible) {\n-\t\t\tout.push(sequence[i]!.id);\n-\t\t\tbreak;\n-\t\t}\n-\t}\n-\tfor (let i = at + 1; i < sequence.length; i++) {\n-\t\tif (sequence[i]!.visible) {\n-\t\t\tout.push(sequence[i]!.id);\n-\t\t\tbreak;\n-\t\t}\n-\t}\n-\treturn out;\n+\treturn view.visibleNeighbours(info.file, line);\n }\n \n /**\n@@ -255,7 +245,7 @@\n \tconst seen = new Set<string>();\n \tfor (const a of [...changed].sort(bySeq(graph))) {\n \t\tif (a === atom.id) continue;\n-\t\tfor (const link of graph.togetherLinks(a)) {\n+\t\tfor (const link of graph.eachTogetherLink(a)) {\n \t\t\tconst b = link.other;\n \t\t\tif (b === atom.id || !set.has(b) || acknowledged.has(b)) continue;\n \t\t\tconst tag = `${a} ${b}`;\n@@ -302,7 +292,7 @@\n \tconst below = graph.closureOf(draft.deps);\n \tconst candidates = new Set<AtomId>();\n \tfor (const key of draft.writes) for (const id of claimersIn(graph, set, key)) candidates.add(id);\n-\tfor (const key of claimsOf(draft)) for (const id of graph.writersOf(key)) if (set.has(id)) candidates.add(id);\n+\tfor (const key of claimsOf(draft)) for (const id of graph.eachWriterOf(key)) if (set.has(id)) candidates.add(id);\n \tconst found: Conflict[] = [];\n \tfor (const id of [...candidates].sort(bySeq(graph))) {\n \t\tconst other = graph.atom(id);"}],"unmatched":[]}