(key: &str, seed: u32)
| 764 | } |
| 765 | |
| 766 | pub fn hash_string(key: &str, seed: u32) -> Id { |
| 767 | let mut hash: u32 = seed; |
| 768 | for b in key.bytes() { |
| 769 | hash = hash.wrapping_add(b as u32); |
| 770 | hash = hash.wrapping_add(hash << 10); |
| 771 | hash ^= hash >> 6; |
| 772 | } |
| 773 | hash = hash.wrapping_add(hash << 3); |
| 774 | hash ^= hash >> 11; |
| 775 | hash = hash.wrapping_add(hash << 15); |
| 776 | Id { |
| 777 | id: hash.wrapping_add(1), |
| 778 | offset: 0, |
| 779 | base_id: hash.wrapping_add(1), |
| 780 | string_id: StringId::from_str(key), |
| 781 | } |
| 782 | } |
| 783 | |
| 784 | pub fn hash_string_with_offset(key: &str, offset: u32, seed: u32) -> Id { |
| 785 | let mut base: u32 = seed; |
no test coverage detected