authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2019-06-05 23:36:51-07:00
committergravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2019-06-05 23:36:51-07:00
log8f4229a61c311c0fc990c34b280ec91010595bc9
treea822798e92bc7e6ad3e1325a76f4c1a2ee7a100c
parent656ac43735094f7cc6b4616cd95e0d427b0174a6

std.HashMap: use std.math.ceilPowerOfTwo


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

std/hash_map.zig+3-3
......@@ -139,9 +139,9 @@ pub fn HashMap(comptime K: type, comptime V: type, comptime hash: fn (key: K) u3
139139 // ensure that the hash map will be at most 60% full if
140140 // expected_count items are put into it
141141 var optimized_capacity = expected_count * 5 / 3;
142 // round capacity to the next power of two
143 const pow = math.log2_int_ceil(usize, optimized_capacity);
144 return math.pow(usize, 2, pow);
142 // an overflow here would mean the amount of memory required would not
143 // be representable in the address space
144 return math.ceilPowerOfTwo(usize, optimized_capacity) catch unreachable;
145145 }
146146
147147 /// Increases capacity so that the hash map will be at most