diff --git a/src/cache_table.zig b/src/cache_table.zig index 2e2a290d5..9f63672e3 100644 --- a/src/cache_table.zig +++ b/src/cache_table.zig @@ -55,6 +55,7 @@ pub fn CacheTable( comptime { assert(std.math.isPowerOfTwo(bucket_count)); + assert(bucket_count <= std.math.maxInt(usize)); } /// `bucket_count` buckets containing `bucket_size` KV pairs each. @@ -79,7 +80,7 @@ pub fn CacheTable( /// make room then it is returned in a struct with its key and value. pub fn put(self: *Self, key: K, value: V) ?KV { const kv: KV = .{ .key = key, .value = value }; - const idx: u64 = self.context.hash(key) % bucket_count; + const idx: usize = @intCast(self.context.hash(key) % bucket_count); // If we have space available in the bucket then we just append if (self.lengths[idx] < bucket_size) { @@ -105,8 +106,7 @@ pub fn CacheTable( /// /// Returns null if no item is found with the provided key. pub fn get(self: *Self, key: K) ?V { - const idx = self.context.hash(key) % bucket_count; - + const idx: usize = @intCast(self.context.hash(key) % bucket_count); const len = self.lengths[idx]; var i: usize = len; while (i > 0) { diff --git a/src/terminal/ref_counted_set.zig b/src/terminal/ref_counted_set.zig index 19d938cfc..65abf5fb1 100644 --- a/src/terminal/ref_counted_set.zig +++ b/src/terminal/ref_counted_set.zig @@ -431,8 +431,7 @@ pub fn RefCountedSet( const hash: u64 = self.context.hash(value); for (0..self.max_psl + 1) |i| { - const p = (hash + i) & self.layout.table_mask; - + const p: usize = @intCast((hash + i) & self.layout.table_mask); const id = table[p]; // Empty bucket, our item cannot have probed to