aboutsummaryrefslogtreecommitdiff
path: root/src/bun.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/bun.zig')
-rw-r--r--src/bun.zig32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/bun.zig b/src/bun.zig
index c4dad48cf..89b92f9fd 100644
--- a/src/bun.zig
+++ b/src/bun.zig
@@ -765,6 +765,34 @@ pub const FDHashMapContext = struct {
}
};
};
+
+pub const U32HashMapContext = struct {
+ pub fn hash(_: @This(), value: u32) u64 {
+ return @intCast(value);
+ }
+ pub fn eql(_: @This(), a: u32, b: u32) bool {
+ return a == b;
+ }
+ pub fn pre(input: u32) Prehashed {
+ return Prehashed{
+ .value = @This().hash(.{}, input),
+ .input = input,
+ };
+ }
+
+ pub const Prehashed = struct {
+ value: u64,
+ input: u32,
+ pub fn hash(this: @This(), value: u32) u64 {
+ if (value == this.input) return this.value;
+ return @intCast(value);
+ }
+
+ pub fn eql(_: @This(), a: u32, b: u32) bool {
+ return a == b;
+ }
+ };
+};
// These wrappers exist to use our strings.eqlLong function
pub const StringArrayHashMapContext = struct {
pub fn hash(_: @This(), s: []const u8) u32 {
@@ -871,6 +899,10 @@ pub fn FDHashMap(comptime Type: type) type {
return std.HashMap(StoredFileDescriptorType, Type, FDHashMapContext, std.hash_map.default_max_load_percentage);
}
+pub fn U32HashMap(comptime Type: type) type {
+ return std.HashMap(u32, Type, U32HashMapContext, std.hash_map.default_max_load_percentage);
+}
+
const CopyFile = @import("./copy_file.zig");
pub const copyFileRange = CopyFile.copyFileRange;
pub const canUseCopyFileRangeSyscall = CopyFile.canUseCopyFileRangeSyscall;