Implement Bytecode Executor for Kym #19
|
@ -287,18 +287,17 @@ pub fn TableTraits(comptime Key: type) type {
|
|||
};
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
return hash_code;
|
||||
}
|
||||
|
||||
pub const string_table_traits = TableTraits([]const io.Byte){
|
||||
.hash = struct {
|
||||
fn hash(key: []const io.Byte) usize {
|
||||
var hash_code = @as(usize, 5381);
|
||||
|
||||
for (key) |byte| {
|
||||
hash_code = ((hash_code << 5) + hash_code) + byte;
|
||||
}
|
||||
|
||||
return hash_code;
|
||||
}
|
||||
}.hash,
|
||||
|
||||
.hash = hash_string,
|
||||
.match = io.equals,
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue