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

Function undelta

atomic-core/examples/semantic_codec_lab/context.rs:5–9  ·  view source on GitHub ↗
(input: &mut &[u8], previous: &mut u64)

Source from the content-addressed store, hash-verified

3use anyhow::{ensure, Context, Result};
4
5fn undelta(input: &mut &[u8], previous: &mut u64) -> Result<u64> {
6 let z = control::get(input)?;
7 *previous = previous.wrapping_add((z >> 1) ^ 0u64.wrapping_sub(z & 1));
8 Ok(*previous)
9}
10fn delta(out: &mut Vec<u8>, previous: &mut u64, n: u64) {
11 let d = n.wrapping_sub(*previous);
12 transforms::put(out, (d << 1) ^ ((d as i64 >> 63) as u64));

Callers 3

split_referencesFunction · 0.70
join_referencesFunction · 0.70
token_bytesFunction · 0.70

Calls 1

getFunction · 0.70

Tested by

no test coverage detected