Skip to main content

static_overlay_state_version

Function static_overlay_state_version 

Source
pub fn static_overlay_state_version(
    doc_highlights: &[Range],
    all_matches: &[Range],
    substitute_matches: &[Range],
) -> u64
Expand description

Perf plan B.2: content hash of the three static-overlay layer payloads. Drives VisibleHighlightsKey::static_overlay_version for the worker’s overlay-bucket invalidation. All-empty payloads hash to 0 so the steady-state no-overlay path stays on a single cheap branch (matches the static_overlay_version: 0 default).

Each layer is tagged with a distinct discriminator byte (0 / 1 / 2) before its ranges are folded in so the SAME range list appearing in different layers produces distinct hashes — avoids accidental cross-layer collisions.

Implementation is a fold over each range’s (start.line, start.byte, end.line, end.byte) quadruple using DefaultHasher (SipHash 1-3, suitable for non-cryptographic versioning). For the bounded sizes the editor enforces (max_hits caps all_matches at 1000; doc_highlights / substitute lists are typically <50) this is sub-µs once per publish.