mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
cache_table and ref_counted_set work on 32-bit machines
This commit is contained in:
@ -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) {
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user