summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaylan Kammer <taylan.kammer@gmail.com>2026-06-01 19:33:57 +0200
committerTaylan Kammer <taylan.kammer@gmail.com>2026-06-01 19:33:57 +0200
commita827524c0e15228ea003b4eca460e085f2086582 (patch)
tree7e116f98a842f7b23defa0392c4c074b04bb47d0
parent19cbe665d0fbcd56fb0dfbba0be3b235cda96302 (diff)
IstrSet: Wrapping addition technically more correct.
-rw-r--r--src/zisp/gc/IstrSet.zig8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/zisp/gc/IstrSet.zig b/src/zisp/gc/IstrSet.zig
index 15af760..d6353a0 100644
--- a/src/zisp/gc/IstrSet.zig
+++ b/src/zisp/gc/IstrSet.zig
@@ -153,7 +153,7 @@ pub fn add(self: *Set, alloc: Alloc, s: []const u8) !IstrPtr {
const idx_init = @as(usize, @truncate(hash & idx_mask));
var idx = idx_init;
- const s_idx = b: while (true) : (idx = (idx + 1) & idx_mask) {
+ const s_idx = b: while (true) : (idx = (idx +% 1) & idx_mask) {
inline for (0..bucket_sectors) |si| {
const sec = sector(self.buckets, idx, si);
if (sec.hash == 0) break :b si;
@@ -194,12 +194,12 @@ fn resize(self: *Set, alloc: Alloc) !void {
var idx = for (old_bs, 0..) |_, idx| {
const s0 = sector(old_bs, idx, 0);
const s1 = sector(old_bs, idx, 1);
- if (s0.hash == 0 or s1.hash == 0) break (idx + 1) & old_mask;
+ if (s0.hash == 0 or s1.hash == 0) break (idx +% 1) & old_mask;
} else unreachable; // Resize strategy guarantees empty slots
const idx_last = (idx -% 1) & old_mask;
- while (idx != idx_last) : (idx = (idx + 1) & old_mask) {
+ while (idx != idx_last) : (idx = (idx +% 1) & old_mask) {
// Need to walk destinations sector by sector, since strings grouped in
// one sector in the old buckets may be split across buckets in the new
// array.
@@ -211,7 +211,7 @@ fn resize(self: *Set, alloc: Alloc) !void {
var dest_hi = new_bs_base + (bucket_size * (idx + old_bc));
// Start copying cluster
- b: while (idx != idx_last) : (idx = (idx + 1) & old_mask) {
+ b: while (idx != idx_last) : (idx = (idx +% 1) & old_mask) {
inline for (0..bucket_sectors) |s_idx| {
const sec = sector(old_bs, idx, s_idx);
if (sec.hash == 0) break :b;