MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / simple_hash

Function simple_hash

cranelift/codegen/shared/src/constant_hash.rs:4–10  ·  view source on GitHub ↗

This module provides a primitive hash function. A primitive hash function for matching opcodes.

(s: &str)

Source from the content-addressed store, hash-verified

2
3/// A primitive hash function for matching opcodes.
4pub 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)]
13mod tests {

Callers 5

lookupMethod · 0.85
from_strMethod · 0.85
test_generate_tableFunction · 0.85
gen_descriptorsFunction · 0.85
gen_opcodesFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_generate_tableFunction · 0.68