From 49cfb347b57d1098ff1b6152a23b703b3ca51984 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 11 Jul 2026 19:56:34 -0700 Subject: [PATCH] terminal: advance set lookup buckets directly Carry the current RefCountedSet bucket through the probe loop instead of recomputing hash plus probe length and narrowing it on every iteration. The bucket remains in the set ID type and wraps with the existing table mask. ReleaseFast timings are seven-run median user CPU times. | Workload | Before | After | Change | | --- | ---: | ---: | ---: | | 128 styles, live lookup | 0.71s | 0.70s | -1.4% | | 4,096 styles, live lookup | 0.89s | 0.85s | -4.5% | | Alternating SGR stream | 1.11s | 1.11s | unchanged | --- src/terminal/ref_counted_set.zig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/terminal/ref_counted_set.zig b/src/terminal/ref_counted_set.zig index fbf407b4e..8dc76363d 100644 --- a/src/terminal/ref_counted_set.zig +++ b/src/terminal/ref_counted_set.zig @@ -593,8 +593,9 @@ pub fn RefCountedSet( const table = self.table.ptr(base); const items = self.items.ptr(base); + var p: Id = @truncate(hash); + p &= self.layout.table_mask; for (0..self.max_psl + 1) |i| { - const p: usize = @intCast((hash +% i) & self.layout.table_mask); const id = table[p]; // Empty bucket, our item cannot have probed to @@ -624,6 +625,8 @@ pub fn RefCountedSet( { return id; } + + p = (p +% 1) & self.layout.table_mask; } return null;