Implement Bytecode Executor for Kym #19

Merged
kayomn merged 9 commits from kym-bytecode-executor into main 2023-07-12 02:58:03 +02:00
1 changed files with 11 additions and 12 deletions
Showing only changes of commit 48f7f97893 - Show all commits

View File

@ -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,
};