diff --git a/vlib/hash/hash_wyhash_test.v b/vlib/hash/hash_wyhash_test.v index 1abfbbdd72..79b752d462 100644 --- a/vlib/hash/hash_wyhash_test.v +++ b/vlib/hash/hash_wyhash_test.v @@ -1,4 +1,4 @@ -import hash as wyhash +module hash struct WyHashTest { s string @@ -13,9 +13,13 @@ fn test_wyhash() { WyHashTest{'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789', 5, 0xe062dfda99413626}, ] for test in tests { - got := wyhash.sum64(test.s.bytes(), test.seed) + got := wyhash64(test.s.str, u64(test.s.len), test.seed) // println(' # GOT: $got | $got.hex()') // println(' # EXPECTED: $test.expected | $test.expected.hex()') assert got == test.expected } + + s := '/v/vmaster/vlib/v/fmt/tests/maps_of_fns_with_string_keys_keep.vv' + x := sum64_string(s, 5).hex_full() + println(x) } diff --git a/vlib/hash/wyhash.v b/vlib/hash/wyhash.v index 160c8f1b7f..8158bd9d12 100644 --- a/vlib/hash/wyhash.v +++ b/vlib/hash/wyhash.v @@ -25,15 +25,16 @@ const ( [inline] pub fn sum64_string(key string, seed u64) u64 { - return wyhash64(key.str, u64(key.len), seed) + return wyhash_c(key.str, u64(key.len), seed) } [inline] pub fn sum64(key []byte, seed u64) u64 { - return wyhash64(&byte(key.data), u64(key.len), seed) + return wyhash_c(&byte(key.data), u64(key.len), seed) } -[inline] +// This is an outdated version of wyhash with memory errors! +[deprecated; inline] fn wyhash64(key &byte, len u64, seed_ u64) u64 { if len == 0 { return 0