mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 07:14:46 +00:00
make hash work for integers/floats/strings
This commit is contained in:
parent
1afd64f7e7
commit
2d63e24843
9 changed files with 88 additions and 18 deletions
|
@ -4,8 +4,23 @@
|
|||
// The MIT license requires this copyright notice to be included in all copies
|
||||
// and substantial portions of the software.
|
||||
const std = @import("std");
|
||||
const str = @import("str.zig");
|
||||
const mem = std.mem;
|
||||
|
||||
pub fn wyhash(seed: u64, bytes: ?[*]const u8, length: usize) callconv(.C) u64 {
|
||||
const stdout = std.io.getStdOut().writer();
|
||||
|
||||
if (bytes) |nonnull| {
|
||||
return wyhash_hash(seed, nonnull[0..length]);
|
||||
} else {
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn wyhash_rocstr(seed: u64, input: str.RocStr) callconv(.C) u64 {
|
||||
return wyhash_hash(seed, input.asSlice());
|
||||
}
|
||||
|
||||
const primes = [_]u64{
|
||||
0xa0761d6478bd642f,
|
||||
0xe7037ed1a0b428db,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue