Skip to main content

Module diffing

Module diffing 

Source
Expand description

Turning two consecutive trees into the delta between them.

Producing a delta is the mirror of composing one, and it has to agree with crate::apply_tree_delta exactly: whatever this emits, the driver applies, and any disagreement shows up as a tree that silently drifts from the screen.

Two rules here are easy to get wrong and both are load-bearing:

  • a node that survives under a parent being removed must be re-sent in changed, even when nothing about it changed, because the removal cascades through it first;
  • rootIds must be sent whenever the inherited list — the base’s roots minus whatever the removals took — is not the list the new tree wants.

Constants§

DELTA_SHARE_CEILING
The point past which a delta stops paying for itself: beyond roughly half the tree, the whole snapshot is cheaper to send and far cheaper to reason about.

Functions§

build_delta
Build the tree-delta body, or None when a whole snapshot is the better answer.
diff_trees
Report what changed, what was removed, the root list when it can no longer be inherited, and whether the cursor moved.