MCPcopy Create free account
hub / github.com/TheRedDeveloper/ply-engine / hash_string

Function hash_string

src/engine.rs:766–782  ·  view source on GitHub ↗
(key: &str, seed: u32)

Source from the content-addressed store, hash-verified

764}
765
766pub 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
784pub fn hash_string_with_offset(key: &str, offset: u32, seed: u32) -> Id {
785 let mut base: u32 = seed;

Callers 5

begin_layoutMethod · 0.85
debug_open_idMethod · 0.85
render_debug_viewMethod · 0.85

Calls 1

bytesMethod · 0.80

Tested by

no test coverage detected