# std: hash_map: optimize isFree/isTombstone \(\#10562\) · gitcafe/zig

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

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

Visibility: public

Requested revision: 9b97edb01223d83095df35d5651572d796baae39

Requested commit: 9b97edb01223d83095df35d5651572d796baae39

Commit: 9b97edb01223d83095df35d5651572d796baae39

Tree: ca8d1d664623a4185f88947d1fde9ab988fe67f0

Author: djg

Committer: Andrew Kelley

## Message

```
std: hash_map: optimize isFree/isTombstone (#10562)

- Add an `Metadata.isFree` helper method.
- Implement `Metadata.isTombstone` and `Metadata.isFree` with `@bitCast` then comparing to a constant. I assume `@bitCast`-then-compare is faster than the old method because it only involves one comparison, and doesn't require bitmasking.
- Summary of benchmarked changes (`gotta-go-fast`, run locally, compared to master):
  - 3/4 of the hash map benchmarks used ~10% fewer cycles
  - The last one (project Euler) shows 4% fewer cycles.

```

## Parents

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

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