Function
delta
(out: &mut Vec<u8>, previous: &mut u64, next: u64)
Source from the content-addressed store, hash-verified
| 91 | anyhow::bail!("graph varint overflow") |
| 92 | } |
| 93 | fn 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 | } |
| 98 | fn 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)); |
Tested by
no test coverage detected