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

Function delta

atomic-core/examples/compact_semantic_codec/codec.rs:53–57  ·  view source on GitHub ↗

Wrapping differences cover the entire u64 domain, including descending IDs.

(out: &mut Vec<u8>, previous: &mut u64, next: u64)

Source from the content-addressed store, hash-verified

51
52// Wrapping differences cover the entire u64 domain, including descending IDs.
53fn delta(out: &mut Vec<u8>, previous: &mut u64, next: u64) {
54 let d = next.wrapping_sub(*previous);
55 put(out, (d << 1) ^ ((d as i64 >> 63) as u64));
56 *previous = next;
57}
58
59fn undelta(input: &mut &[u8], previous: &mut u64) -> Result<u64> {
60 let z = get(input)?;

Callers 5

idMethod · 0.70
optional_numberMethod · 0.70
bytesMethod · 0.70
encodeFunction · 0.70

Calls 1

putFunction · 0.70

Tested by 1