Skip to main content

diff_piece_trees

Function diff_piece_trees 

Source
pub fn diff_piece_trees(
    before: &Arc<PieceTreeNode>,
    after: &Arc<PieceTreeNode>,
    line_counter: &dyn Fn(&LeafData, usize, usize) -> Option<usize>,
) -> PieceTreeDiff
Expand description

Compute a diff between two piece tree roots.

Uses structural sharing (Arc::ptr_eq) to skip identical subtrees in O(1), falling back to leaf-level comparison only for subtrees that actually differ. After path-copying edits, this is O(changed_path) instead of O(all_leaves).

line_counter should return the number of line feeds in a slice of a leaf. If it returns None for any consulted slice, the diff will have line_range=None.