| 995 | } |
| 996 | |
| 997 | fn hash(&self, suffix: &SuffixCacheKey) -> usize { |
| 998 | // Basic FNV-1a hash as described: |
| 999 | // https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function |
| 1000 | const FNV_PRIME: u64 = 1099511628211; |
| 1001 | let mut h = 14695981039346656037; |
| 1002 | h = (h ^ (suffix.from_inst as u64)).wrapping_mul(FNV_PRIME); |
| 1003 | h = (h ^ (suffix.start as u64)).wrapping_mul(FNV_PRIME); |
| 1004 | h = (h ^ (suffix.end as u64)).wrapping_mul(FNV_PRIME); |
| 1005 | (h as usize) % self.sparse.len() |
| 1006 | } |
| 1007 | } |
| 1008 | |
| 1009 | struct ByteClassSet([bool; 256]); |