This module provides a primitive hash function. A primitive hash function for matching opcodes.
(s: &str)
| 2 | |
| 3 | /// A primitive hash function for matching opcodes. |
| 4 | pub fn simple_hash(s: &str) -> usize { |
| 5 | let mut h: u32 = 5381; |
| 6 | for c in s.chars() { |
| 7 | h = (h ^ c as u32).wrapping_add(h.rotate_right(6)); |
| 8 | } |
| 9 | h as usize |
| 10 | } |
| 11 | |
| 12 | #[cfg(test)] |
| 13 | mod tests { |
no outgoing calls