fuzzy_regex/engine/
hash.rs1use std::collections::{HashMap, HashSet};
7use std::hash::{BuildHasherDefault, Hasher};
8
9#[derive(Default)]
12pub struct FxHasher {
13 hash: u64,
14}
15
16impl Hasher for FxHasher {
17 #[inline]
18 fn write(&mut self, bytes: &[u8]) {
19 const K: u64 = 0x517c_c1b7_2722_0a95;
20 for &byte in bytes {
21 self.hash = (self.hash.rotate_left(5) ^ u64::from(byte)).wrapping_mul(K);
22 }
23 }
24
25 #[inline]
26 fn finish(&self) -> u64 {
27 self.hash
28 }
29}
30
31pub type FxHashMap<K, V> = HashMap<K, V, BuildHasherDefault<FxHasher>>;
33
34pub type FxHashSet<K> = HashSet<K, BuildHasherDefault<FxHasher>>;