commit ba6531a9c94844f78e6660bf07642180549080b7
parent fc502aa4aca5017d18609a2ccb44427c31922d0e
Author: Drew DeVault <sir@cmpwn.com>
Date: Fri, 19 Nov 2021 18:03:18 +0100
hash::fnv: add string
Signed-off-by: Drew DeVault <sir@cmpwn.com>
Diffstat:
1 file changed, 3 insertions(+), 0 deletions(-)
diff --git a/hash/fnv/fnv.ha b/hash/fnv/fnv.ha
@@ -18,6 +18,9 @@ export type state64 = struct {
v: u64,
};
+// Hashes a string, returning a size key, for use in a hash map.
+export fn string(s: str) size = string64(s): size;
+
// Hashes a string, returning a 32-bit key.
export fn string32(s: str) u32 = {
let hash = fnv32a();