mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 20:54:43 +00:00
chunking robot store hashing
This commit is contained in:
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user