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(
280280 if (it.index >= it.len) return null;
281281 const result = Entry{
282282 .key_ptr = &it.keys[it.index],
283 // workaround for #6974
284 .value_ptr = if (@sizeOf(*V) == 0) undefined else &it.values[it.index],
283 .value_ptr = &it.values[it.index],
285284 };
286285 it.index += 1;
287286 return result;
......@@ -323,8 +322,7 @@ pub fn Custom(
323322 const slice = self.entries.slice();
324323 return GetOrPutResult{
325324 .key_ptr = &slice.items(.key)[index],
326 // workaround for #6974
327 .value_ptr = if (@sizeOf(*V) == 0) undefined else &slice.items(.value)[index],
325 .value_ptr = &slice.items(.value)[index],
328326 .found_existing = true,
329327 .index = index,
330328 };
......@@ -369,8 +367,7 @@ pub fn Custom(
369367 if (hashes_array[i] == h and checkedEql(ctx, key, item_key.*, i)) {
370368 return GetOrPutResult{
371369 .key_ptr = item_key,
372 // workaround for #6974
373 .value_ptr = if (@sizeOf(*V) == 0) undefined else &slice.items(.value)[i],
370 .value_ptr = &slice.items(.value)[i],
374371 .found_existing = true,
375372 .index = i,
376373 };
......@@ -383,8 +380,7 @@ pub fn Custom(
383380
384381 return GetOrPutResult{
385382 .key_ptr = &keys_array.ptr[index],
386 // workaround for #6974
387 .value_ptr = if (@sizeOf(*V) == 0) undefined else &slice.items(.value).ptr[index],
383 .value_ptr = &slice.items(.value).ptr[index],
388384 .found_existing = false,
389385 .index = index,
390386 };
......@@ -569,8 +565,7 @@ pub fn Custom(
569565 const slice = self.entries.slice();
570566 return Entry{
571567 .key_ptr = &slice.items(.key)[index],
572 // workaround for #6974
573 .value_ptr = if (@sizeOf(*V) == 0) undefined else &slice.items(.value)[index],
568 .value_ptr = &slice.items(.value)[index],
574569 };
575570 }
576571
......@@ -634,8 +629,7 @@ pub fn Custom(
634629 }
635630 pub fn getPtrAdapted(self: Self, key: anytype, ctx: anytype) ?*V {
636631 const index = self.getIndexAdapted(key, ctx) orelse return null;
637 // workaround for #6974
638 return if (@sizeOf(*V) == 0) @as(*V, undefined) else &self.values()[index];
632 return &self.values()[index];
639633 }
640634
641635 /// Find the actual key associated with an adapted key
......@@ -1314,8 +1308,7 @@ pub fn Custom(
13141308 return .{
13151309 .found_existing = false,
13161310 .key_ptr = &keys_array.ptr[new_index],
1317 // workaround for #6974
1318 .value_ptr = if (@sizeOf(*V) == 0) undefined else &values_array.ptr[new_index],
1311 .value_ptr = &values_array.ptr[new_index],
13191312 .index = new_index,
13201313 };
13211314 }
......@@ -1328,8 +1321,7 @@ pub fn Custom(
13281321 return .{
13291322 .found_existing = true,
13301323 .key_ptr = &keys_array[slot_data.entry_index],
1331 // workaround for #6974
1332 .value_ptr = if (@sizeOf(*V) == 0) undefined else &values_array[slot_data.entry_index],
1324 .value_ptr = &values_array[slot_data.entry_index],
13331325 .index = slot_data.entry_index,
13341326 };
13351327 }
......@@ -1370,8 +1362,7 @@ pub fn Custom(
13701362 return .{
13711363 .found_existing = false,
13721364 .key_ptr = &keys_array.ptr[new_index],
1373 // workaround for #6974
1374 .value_ptr = if (@sizeOf(*V) == 0) undefined else &values_array.ptr[new_index],
1365 .value_ptr = &values_array.ptr[new_index],
13751366 .index = new_index,
13761367 };
13771368 }