authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-04-20 03:12:33+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-04-20 16:49:52+02:00
log259e4cf9fd07c4384e4ced614cc7bf26e2631e46
tree62d6117543dde9c4214ebefe4e3c1609e8b2304d
parent4e2147d14e34e6891f2a8f2e2c7f28fdb6d92c2a

std.ArrayHashMap: this workaround is no longer necessary


1 files changed, 9 insertions(+), 18 deletions(-)

lib/std/array_hash_map.zig+9-18
...@@ -280,8 +280,7 @@ pub fn Custom(...@@ -280,8 +280,7 @@ pub fn Custom(
280 if (it.index >= it.len) return null;280 if (it.index >= it.len) return null;
281 const result = Entry{281 const result = Entry{
282 .key_ptr = &it.keys[it.index],282 .key_ptr = &it.keys[it.index],
283 // workaround for #6974283 .value_ptr = &it.values[it.index],
284 .value_ptr = if (@sizeOf(*V) == 0) undefined else &it.values[it.index],
285 };284 };
286 it.index += 1;285 it.index += 1;
287 return result;286 return result;
...@@ -323,8 +322,7 @@ pub fn Custom(...@@ -323,8 +322,7 @@ pub fn Custom(
323 const slice = self.entries.slice();322 const slice = self.entries.slice();
324 return GetOrPutResult{323 return GetOrPutResult{
325 .key_ptr = &slice.items(.key)[index],324 .key_ptr = &slice.items(.key)[index],
326 // workaround for #6974325 .value_ptr = &slice.items(.value)[index],
327 .value_ptr = if (@sizeOf(*V) == 0) undefined else &slice.items(.value)[index],
328 .found_existing = true,326 .found_existing = true,
329 .index = index,327 .index = index,
330 };328 };
...@@ -369,8 +367,7 @@ pub fn Custom(...@@ -369,8 +367,7 @@ pub fn Custom(
369 if (hashes_array[i] == h and checkedEql(ctx, key, item_key.*, i)) {367 if (hashes_array[i] == h and checkedEql(ctx, key, item_key.*, i)) {
370 return GetOrPutResult{368 return GetOrPutResult{
371 .key_ptr = item_key,369 .key_ptr = item_key,
372 // workaround for #6974370 .value_ptr = &slice.items(.value)[i],
373 .value_ptr = if (@sizeOf(*V) == 0) undefined else &slice.items(.value)[i],
374 .found_existing = true,371 .found_existing = true,
375 .index = i,372 .index = i,
376 };373 };
...@@ -383,8 +380,7 @@ pub fn Custom(...@@ -383,8 +380,7 @@ pub fn Custom(
383380
384 return GetOrPutResult{381 return GetOrPutResult{
385 .key_ptr = &keys_array.ptr[index],382 .key_ptr = &keys_array.ptr[index],
386 // workaround for #6974383 .value_ptr = &slice.items(.value).ptr[index],
387 .value_ptr = if (@sizeOf(*V) == 0) undefined else &slice.items(.value).ptr[index],
388 .found_existing = false,384 .found_existing = false,
389 .index = index,385 .index = index,
390 };386 };
...@@ -569,8 +565,7 @@ pub fn Custom(...@@ -569,8 +565,7 @@ pub fn Custom(
569 const slice = self.entries.slice();565 const slice = self.entries.slice();
570 return Entry{566 return Entry{
571 .key_ptr = &slice.items(.key)[index],567 .key_ptr = &slice.items(.key)[index],
572 // workaround for #6974568 .value_ptr = &slice.items(.value)[index],
573 .value_ptr = if (@sizeOf(*V) == 0) undefined else &slice.items(.value)[index],
574 };569 };
575 }570 }
576571
...@@ -634,8 +629,7 @@ pub fn Custom(...@@ -634,8 +629,7 @@ pub fn Custom(
634 }629 }
635 pub fn getPtrAdapted(self: Self, key: anytype, ctx: anytype) ?*V {630 pub fn getPtrAdapted(self: Self, key: anytype, ctx: anytype) ?*V {
636 const index = self.getIndexAdapted(key, ctx) orelse return null;631 const index = self.getIndexAdapted(key, ctx) orelse return null;
637 // workaround for #6974632 return &self.values()[index];
638 return if (@sizeOf(*V) == 0) @as(*V, undefined) else &self.values()[index];
639 }633 }
640634
641 /// Find the actual key associated with an adapted key635 /// Find the actual key associated with an adapted key
...@@ -1314,8 +1308,7 @@ pub fn Custom(...@@ -1314,8 +1308,7 @@ pub fn Custom(
1314 return .{1308 return .{
1315 .found_existing = false,1309 .found_existing = false,
1316 .key_ptr = &keys_array.ptr[new_index],1310 .key_ptr = &keys_array.ptr[new_index],
1317 // workaround for #69741311 .value_ptr = &values_array.ptr[new_index],
1318 .value_ptr = if (@sizeOf(*V) == 0) undefined else &values_array.ptr[new_index],
1319 .index = new_index,1312 .index = new_index,
1320 };1313 };
1321 }1314 }
...@@ -1328,8 +1321,7 @@ pub fn Custom(...@@ -1328,8 +1321,7 @@ pub fn Custom(
1328 return .{1321 return .{
1329 .found_existing = true,1322 .found_existing = true,
1330 .key_ptr = &keys_array[slot_data.entry_index],1323 .key_ptr = &keys_array[slot_data.entry_index],
1331 // workaround for #69741324 .value_ptr = &values_array[slot_data.entry_index],
1332 .value_ptr = if (@sizeOf(*V) == 0) undefined else &values_array[slot_data.entry_index],
1333 .index = slot_data.entry_index,1325 .index = slot_data.entry_index,
1334 };1326 };
1335 }1327 }
...@@ -1370,8 +1362,7 @@ pub fn Custom(...@@ -1370,8 +1362,7 @@ pub fn Custom(
1370 return .{1362 return .{
1371 .found_existing = false,1363 .found_existing = false,
1372 .key_ptr = &keys_array.ptr[new_index],1364 .key_ptr = &keys_array.ptr[new_index],
1373 // workaround for #69741365 .value_ptr = &values_array.ptr[new_index],
1374 .value_ptr = if (@sizeOf(*V) == 0) undefined else &values_array.ptr[new_index],
1375 .index = new_index,1366 .index = new_index,
1376 };1367 };
1377 }1368 }