Fix default string hashing mechanism
This commit is contained in:
parent
7b266fde58
commit
48f7f97893
|
@ -287,18 +287,17 @@ pub fn TableTraits(comptime Key: type) type {
|
|||
};
|
||||
}
|
||||
|
||||
pub const string_table_traits = TableTraits([]const io.Byte){
|
||||
.hash = struct {
|
||||
fn hash(key: []const io.Byte) usize {
|
||||
fn hash_string(key: []const io.Byte) usize {
|
||||
var hash_code = @as(usize, 5381);
|
||||
|
||||
for (key) |byte| {
|
||||
hash_code = ((hash_code << 5) + hash_code) + byte;
|
||||
hash_code = ((hash_code << 5) +% hash_code) +% byte;
|
||||
}
|
||||
|
||||
return hash_code;
|
||||
}
|
||||
}.hash,
|
||||
|
||||
pub const string_table_traits = TableTraits([]const io.Byte){
|
||||
.hash = hash_string,
|
||||
.match = io.equals,
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue