authorgravatar for der.teufel.mail@gmail.comKrzysztof Wolicki <der.teufel.mail@gmail.com> 2026-01-27 20:49:30+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-28 03:13:37+01:00
log204fa8959a8f9d5457705f338eb0461e54155796
tree0d8df6c6cabbbd8a3717f688fbb9e2f187e50330
parent11c3b4bd4178c78af103f5397fc3aafd09a2a979

Make functions on EnumMap always take a pointer to avoid copies of big EnumMaps


1 files changed, 4 insertions(+), 4 deletions(-)

lib/std/enums.zig+4-4
......@@ -504,25 +504,25 @@ pub fn EnumMap(comptime E: type, comptime V: type) type {
504504 }
505505
506506 /// The number of items in the map.
507 pub fn count(self: Self) usize {
507 pub fn count(self: *const Self) usize {
508508 return self.bits.count();
509509 }
510510
511511 /// Checks if the map contains an item.
512 pub fn contains(self: Self, key: Key) bool {
512 pub fn contains(self: *const Self, key: Key) bool {
513513 return self.bits.isSet(Indexer.indexOf(key));
514514 }
515515
516516 /// Gets the value associated with a key.
517517 /// If the key is not in the map, returns null.
518 pub fn get(self: Self, key: Key) ?Value {
518 pub fn get(self: *const Self, key: Key) ?Value {
519519 const index = Indexer.indexOf(key);
520520 return if (self.bits.isSet(index)) self.values[index] else null;
521521 }
522522
523523 /// Gets the value associated with a key, which must
524524 /// exist in the map.
525 pub fn getAssertContains(self: Self, key: Key) Value {
525 pub fn getAssertContains(self: *const Self, key: Key) Value {
526526 const index = Indexer.indexOf(key);
527527 assert(self.bits.isSet(index));
528528 return self.values[index];