# std.HashMap: cleanup ensureCapacity \+ add test · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/cf8dde2d686199474847c6c4e342dc1ac46a435b)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: cf8dde2d686199474847c6c4e342dc1ac46a435b

Requested commit: cf8dde2d686199474847c6c4e342dc1ac46a435b

Commit: cf8dde2d686199474847c6c4e342dc1ac46a435b

Tree: 5cfe5b3a15d3c396d77acc578408f359bb98799b

Author: Ryan Liptak

Committer: Ryan Liptak

## Message

```
std.HashMap: cleanup ensureCapacity + add test

- Cleaned up some comments
- Removed the "is power of two" check from optimizedCapacity since the * 5 / 3 is unlikely to end up with a power of two, so it's a wasted check the majority of the time
- Made ensureCapacity/ensureCapacityExact increment the modification count if they resize the hash map so that we can catch resizes while iterating, which would likely break the iterator state

```

## Parents

- [13a7b8586a600c117cc2d090a283e5a6344d42c4](https://git.cafe/gitcafe/zig/commit/13a7b8586a600c117cc2d090a283e5a6344d42c4?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/cf8dde2d686199474847c6c4e342dc1ac46a435b?format=markdown)
