pub fn smhasher(comptime hash_fn: anytype) u32 hash_fn29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44pub fn smhasher(comptime hash_fn: anytype) u32 {
const HashFnTy = @typeInfo(@TypeOf(hash_fn)).@"fn";
const HashResult = HashFnTy.return_type.?;
const hash_size = @sizeOf(HashResult);
var buf: [256]u8 = undefined;
var buf_all: [256 * hash_size]u8 = undefined;
for (0..256) |i| {
buf[i] = @intCast(i);
const h = hashMaybeSeed(hash_fn, 256 - i, buf[0..i]);
std.mem.writeInt(HashResult, buf_all[i * hash_size ..][0..hash_size], h, .little);
}
return @truncate(hashMaybeSeed(hash_fn, 0, buf_all[0..]));
}