authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2019-05-02 17:42:38-07:00
committergravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2019-05-02 17:42:38-07:00
log26591d4f2264c3f6636598dc86d4e4bed528658e
treec89c49e49cf5a88aeeb88373d24b769d17013544
parent4d42275d03a3f24beca2d93e02ff12e52a48a91b

std.HashMap: add putAssumeCapacity fn


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

std/hash_map.zig+6-1
......@@ -181,8 +181,13 @@ pub fn HashMap(comptime K: type, comptime V: type, comptime hash: fn (key: K) u3
181181
182182 /// Returns the kv pair that was already there.
183183 pub fn put(self: *Self, key: K, value: V) !?KV {
184 self.incrementModificationCount();
185184 try self.autoCapacity();
185 return putAssumeCapacity(self, key, value);
186 }
187
188 pub fn putAssumeCapacity(self: *Self, key: K, value: V) ?KV {
189 assert(self.count() < self.entries.len);
190 self.incrementModificationCount();
186191
187192 const put_result = self.internalPut(key);
188193 put_result.new_entry.kv.value = value;