Skip to main content

read_signed_varint

Function read_signed_varint 

Source
fn read_signed_varint<const N: usize>(
    data: &mut &[u8],
    tag: Tag,
    first: Tag,
) -> [u8; N]
Expand description

Read the payload of a variable-length integer of either sign, extended to N bytes.

A signed family alternates the two signs at each payload width, so the tag’s distance from first holds the width above its low bit and the sign in it. Both fall out by shifting and masking, with no compare and nothing to dispatch on: a column’s tag varies with the magnitude and sign of every value, so any branch on it is one the predictor cannot learn.

§Correctness

tag must belong to the family starting at first, and data must hold its payload.