pub(crate) fn merge_sorted_tail(
perm: &mut Vec<EntryId>,
batch: &[EntryId],
cmp: impl Fn(EntryId, EntryId) -> Ordering,
)Expand description
Merge sorted batch into perm in place: each batch element
binary-searches its insertion point and the segments between insertion
points move once with copy_within — O(batch·log n) comparisons +
O(moved) memmove + no allocation (ADR-0008).
Old elements are never reordered, and on a sorted array the strict
total order (cmp id tie-break) makes the result the unique sorted
merge. Arrays ordered by size/mtime can be locally stale-sorted
(in-place update_stat never repositions an entry); placement there is
deterministic best-effort.