chunking robot store hashing

This commit is contained in:
Muki Kiboigo
2026-02-12 22:55:40 -08:00
parent 576dbb7ce6
commit 308fd92a46

View File

@@ -86,11 +86,22 @@ pub const RobotStore = struct {
const Context = @This(); const Context = @This();
pub fn hash(_: Context, value: []const u8) u32 { pub fn hash(_: Context, value: []const u8) u32 {
var hasher = std.hash.Wyhash.init(value.len); var key = value;
for (value) |c| { var buf: [128]u8 = undefined;
std.hash.autoHash(&hasher, std.ascii.toLower(c)); var h = std.hash.Wyhash.init(value.len);
while (key.len >= 128) {
const lower = std.ascii.lowerString(buf[0..], key[0..128]);
h.update(lower);
key = key[128..];
} }
return @truncate(hasher.final());
if (key.len > 0) {
const lower = std.ascii.lowerString(buf[0..key.len], key);
h.update(lower);
}
return @truncate(h.final());
} }
pub fn eql(_: Context, a: []const u8, b: []const u8) bool { pub fn eql(_: Context, a: []const u8, b: []const u8) bool {