MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / delta

Function delta

atomic-core/examples/graph_codec_lab/codec.rs:93–97  ·  view source on GitHub ↗
(out: &mut Vec<u8>, previous: &mut u64, next: u64)

Source from the content-addressed store, hash-verified

91 anyhow::bail!("graph varint overflow")
92}
93fn delta(out: &mut Vec<u8>, previous: &mut u64, next: u64) {
94 let d = next.wrapping_sub(*previous);
95 put(out, (d << 1) ^ ((d as i64 >> 63) as u64));
96 *previous = next;
97}
98fn undelta(input: &mut &[u8], previous: &mut u64) -> Result<u64> {
99 let z = get(input)?;
100 *previous = previous.wrapping_add((z >> 1) ^ 0u64.wrapping_sub(z & 1));

Callers 2

columnMethod · 0.70
referenceMethod · 0.70

Calls 1

putFunction · 0.70

Tested by

no test coverage detected