diff options
Diffstat (limited to 'src/bun.zig')
-rw-r--r-- | src/bun.zig | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/bun.zig b/src/bun.zig index a9528aa64..2845721c7 100644 --- a/src/bun.zig +++ b/src/bun.zig @@ -444,6 +444,11 @@ pub fn hash(content: []const u8) u64 { return std.hash.Wyhash.hash(0, content); } +pub fn hash32(content: []const u8) u32 { + const res = hash(content); + return @truncate(u32, res); +} + pub const HiveArray = @import("./hive_array.zig").HiveArray; pub fn rand(bytes: []u8) void { @@ -606,6 +611,20 @@ pub const StringArrayHashMapContext = struct { pub fn eql(_: @This(), a: []const u8, b: []const u8, _: usize) bool { return strings.eqlLong(a, b, true); } + + pub const Prehashed = struct { + value: u32, + input: []const u8, + pub fn hash(this: @This(), s: []const u8) u32 { + if (s.ptr == this.input.ptr and s.len == this.input.len) + return this.value; + return @truncate(u32, std.hash.Wyhash.hash(0, s)); + } + + pub fn eql(_: @This(), a: []const u8, b: []const u8) bool { + return strings.eqlLong(a, b, true); + } + }; }; pub const StringHashMapContext = struct { @@ -953,3 +972,5 @@ pub const fast_debug_build_mode = false and Environment.isDebug; pub const MultiArrayList = @import("./multi_array_list.zig").MultiArrayList; + +pub const Joiner = @import("./string_joiner.zig"); |