# std.HashMap: optimize indexing by avoiding modulo operator · gitcafe/zig

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

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

Visibility: public

Requested revision: 656ac43735094f7cc6b4616cd95e0d427b0174a6

Requested commit: 656ac43735094f7cc6b4616cd95e0d427b0174a6

Commit: 656ac43735094f7cc6b4616cd95e0d427b0174a6

Tree: a38992b496f6bb148f3010e5f1525d5a3d402d79

Author: Ryan Liptak

Committer: Ryan Liptak

## Message

```
std.HashMap: optimize indexing by avoiding modulo operator

x % y can be optimized if y is a power of two by doing x & (y-1) instead. HashMap already enforces power of two capacity, so we can take advantage of this optimization.

```

## Parents

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

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