aboutsummaryrefslogtreecommitdiff
path: root/src/InternPool.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2024-12-09 18:04:26 -0500
committerGitHub <noreply@github.com>2024-12-09 18:04:26 -0500
commit8245d7fac0400d7e9de2a6fd4cfbc3609ad0f201 (patch)
treeb7d46c56f96bbf32397b71479c85f3e363e48672 /src/InternPool.zig
parent3aab81b0abe2efeab8a2c7cdae2146252b4f703f (diff)
parent135c733eefa8cd43e84e7b39aa292359c680fe1e (diff)
downloadzig-8245d7fac0400d7e9de2a6fd4cfbc3609ad0f201.tar.gz
zig-8245d7fac0400d7e9de2a6fd4cfbc3609ad0f201.zip
Merge pull request #22164 from mlugg/astgen-ref-dedup
AstGen: correctly deduplicate `ref` of `param` and `alloc_inferred`
Diffstat (limited to 'src/InternPool.zig')
-rw-r--r--src/InternPool.zig4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/InternPool.zig b/src/InternPool.zig
index 63cdd7cec8..bbbcb953f6 100644
--- a/src/InternPool.zig
+++ b/src/InternPool.zig
@@ -314,7 +314,9 @@ pub fn rehashTrackedInsts(
// We know how big each shard must be, so ensure we have the capacity we need.
for (ip.shards) |*shard| {
- const want_capacity = std.math.ceilPowerOfTwo(u32, shard.mutate.tracked_inst_map.len * 5 / 3) catch unreachable;
+ const want_capacity = if (shard.mutate.tracked_inst_map.len == 0) 0 else cap: {
+ break :cap std.math.ceilPowerOfTwo(u32, shard.mutate.tracked_inst_map.len * 5 / 3) catch unreachable;
+ };
const have_capacity = shard.shared.tracked_inst_map.header().capacity; // no acquire because we hold the mutex
if (have_capacity >= want_capacity) {
@memset(shard.shared.tracked_inst_map.entries[0..have_capacity], .{ .value = .none, .hash = undefined });