unreal-niggery-rs/src/fnv.rs
2025-01-24 01:09:41 +01:00

15 lines
No EOL
367 B
Rust

#[inline(always)]
pub fn fnv_hash(prime: u32, initial_value: u32, data: &[u16]) -> u32 {
let mut hash: u32 = initial_value;
if data.len() == 0 {
return hash;
}
for element in data {
hash = (*element as u32 ^ hash).wrapping_mul(prime);
}
hash
}
pub fn ue_gas_fnv_hash(data: &[u16]) -> u32 {
fnv_hash(0x1000193, 0x0, data)
}