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 {...@@ -504,25 +504,25 @@ pub fn EnumMap(comptime E: type, comptime V: type) type {
504 }504 }
505505
506 /// The number of items in the map.506 /// The number of items in the map.
507 pub fn count(self: Self) usize {507 pub fn count(self: *const Self) usize {
508 return self.bits.count();508 return self.bits.count();
509 }509 }
510510
511 /// Checks if the map contains an item.511 /// 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 {
513 return self.bits.isSet(Indexer.indexOf(key));513 return self.bits.isSet(Indexer.indexOf(key));
514 }514 }
515515
516 /// Gets the value associated with a key.516 /// Gets the value associated with a key.
517 /// If the key is not in the map, returns null.517 /// 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 {
519 const index = Indexer.indexOf(key);519 const index = Indexer.indexOf(key);
520 return if (self.bits.isSet(index)) self.values[index] else null;520 return if (self.bits.isSet(index)) self.values[index] else null;
521 }521 }
522522
523 /// Gets the value associated with a key, which must523 /// Gets the value associated with a key, which must
524 /// exist in the map.524 /// exist in the map.
525 pub fn getAssertContains(self: Self, key: Key) Value {525 pub fn getAssertContains(self: *const Self, key: Key) Value {
526 const index = Indexer.indexOf(key);526 const index = Indexer.indexOf(key);
527 assert(self.bits.isSet(index));527 assert(self.bits.isSet(index));
528 return self.values[index];528 return self.values[index];