diff options
author | 2023-07-11 19:14:34 -0700 | |
---|---|---|
committer | 2023-07-11 19:14:34 -0700 | |
commit | cbb88672f217a90db1aa1eb29cd92d5d9035b22b (patch) | |
tree | 43a00501f3cde495967e116f0b660777051551f8 /src/allocators.zig | |
parent | 1f900cff453700b19bca2acadfe26da4468c1282 (diff) | |
parent | 34b0e7a2bbd8bf8097341cdb0075d0908283e834 (diff) | |
download | bun-cbb88672f217a90db1aa1eb29cd92d5d9035b22b.tar.gz bun-cbb88672f217a90db1aa1eb29cd92d5d9035b22b.tar.zst bun-cbb88672f217a90db1aa1eb29cd92d5d9035b22b.zip |
Merge branch 'main' into jarred/esm-conditionsjarred/esm-conditions
Diffstat (limited to 'src/allocators.zig')
-rw-r--r-- | src/allocators.zig | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/allocators.zig b/src/allocators.zig index 2827214af..1d3b30c0b 100644 --- a/src/allocators.zig +++ b/src/allocators.zig @@ -2,19 +2,18 @@ const std = @import("std"); const FeatureFlags = @import("./feature_flags.zig"); const Environment = @import("./env.zig"); -const Wyhash = std.hash.Wyhash; const FixedBufferAllocator = std.heap.FixedBufferAllocator; const constStrToU8 = @import("root").bun.constStrToU8; const bun = @import("root").bun; pub fn isSliceInBuffer(slice: anytype, buffer: anytype) bool { - return (@ptrToInt(&buffer) <= @ptrToInt(slice.ptr) and (@ptrToInt(slice.ptr) + slice.len) <= (@ptrToInt(buffer) + buffer.len)); + return (@intFromPtr(&buffer) <= @intFromPtr(slice.ptr) and (@intFromPtr(slice.ptr) + slice.len) <= (@intFromPtr(buffer) + buffer.len)); } pub fn sliceRange(slice: []const u8, buffer: []const u8) ?[2]u32 { - return if (@ptrToInt(buffer.ptr) <= @ptrToInt(slice.ptr) and - (@ptrToInt(slice.ptr) + slice.len) <= (@ptrToInt(buffer.ptr) + buffer.len)) + return if (@intFromPtr(buffer.ptr) <= @intFromPtr(slice.ptr) and + (@intFromPtr(slice.ptr) + slice.len) <= (@intFromPtr(buffer.ptr) + buffer.len)) [2]u32{ - @truncate(u32, @ptrToInt(slice.ptr) - @ptrToInt(buffer.ptr)), + @truncate(u32, @intFromPtr(slice.ptr) - @intFromPtr(buffer.ptr)), @truncate(u32, slice.len), } else @@ -53,7 +52,6 @@ pub const Result = struct { return r.index >= count; } }; -const Seed = 999; pub const NotFound = IndexType{ .index = std.math.maxInt(u31), @@ -488,7 +486,7 @@ pub fn BSSMap(comptime ValueType: type, comptime count: anytype, comptime store_ pub fn getOrPut(self: *Self, denormalized_key: []const u8) !Result { const key = if (comptime remove_trailing_slashes) std.mem.trimRight(u8, denormalized_key, "/") else denormalized_key; - const _key = Wyhash.hash(Seed, key); + const _key = bun.hash(key); self.mutex.lock(); defer self.mutex.unlock(); @@ -516,7 +514,7 @@ pub fn BSSMap(comptime ValueType: type, comptime count: anytype, comptime store_ pub fn get(self: *Self, denormalized_key: []const u8) ?*ValueType { const key = if (comptime remove_trailing_slashes) std.mem.trimRight(u8, denormalized_key, "/") else denormalized_key; - const _key = Wyhash.hash(Seed, key); + const _key = bun.hash(key); self.mutex.lock(); defer self.mutex.unlock(); const index = self.index.get(_key) orelse return null; @@ -577,7 +575,7 @@ pub fn BSSMap(comptime ValueType: type, comptime count: anytype, comptime store_ const key = if (comptime remove_trailing_slashes) std.mem.trimRight(u8, denormalized_key, "/") else denormalized_key; - const _key = Wyhash.hash(Seed, key); + const _key = bun.hash(key); _ = self.index.remove(_key); // const index = self.index.get(_key) orelse return; // switch (index) { |