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

Method compute_hash

atomic-core/src/diff/line.rs:276–287  ·  view source on GitHub ↗
(content: &[u8])

Source from the content-addressed store, hash-verified

274 /// - Simplicity: Easy to implement and understand
275 #[inline]
276 fn compute_hash(content: &[u8]) -> u64 {
277 // FNV-1a parameters for 64-bit
278 const FNV_OFFSET_BASIS: u64 = 0xcbf29ce484222325;
279 const FNV_PRIME: u64 = 0x100000001b3;
280
281 let mut hash = FNV_OFFSET_BASIS;
282 for &byte in content {
283 hash ^= byte as u64;
284 hash = hash.wrapping_mul(FNV_PRIME);
285 }
286 hash
287 }
288
289 /// Compare two lines for equality, optionally ignoring trailing newline differences.
290 ///

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected