Skip to main content

Module compute

Module compute 

Source
Expand description

Hunk computation: the engine’s single public entry point is compute_diff, which dispatches by participant count to crate-private [two_way] / [three_way] helpers. External consumers (subsystem, benches, integration tests in other crates) go through compute_diff exclusively — no code outside this crate branches on arity. v1 supports N ∈ {0, 1, 2, 3}; N=0 errors as Empty, N=1 returns an empty HunkIndex (dormant session, no peers to diff against), N=2 / N=3 dispatch to the named helpers, N≥4 errors as Unsupported. See docs/dev/architecture/n-way-diff-membership.md (D.8) for the rationale.

Both helpers materialise the input ropes to strings, tokenise by line, and run imara-diff. The two-way path is a thin wrapper around the engine; the three-way path composes two two-way diffs against the base and merges them by overlapping base ranges, producing Conflict hunks where both sides independently touched the same base lines.

See docs/dev/architecture/diff-system.md §3 and §4.

Enums§

DiffEngineError
D.8.a: errors compute_diff returns for unsupported participant counts. v1’s cap (N ≤ 3) is enforced here, not in the descriptor / subsystem layer — moving the cap means extending the Unsupported arm with new computation.

Functions§

compute_diff
D.8.a: the engine’s only public dispatch entry. Routes by sources.len() to the appropriate algorithm, returning a typed error for arities outside the supported range.