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

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

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

Visibility: public

Requested revision: 4731a6e5d57d5fe6c17c42028aebd9fce3682ddb

Requested commit: 4731a6e5d57d5fe6c17c42028aebd9fce3682ddb

Commit: 4731a6e5d57d5fe6c17c42028aebd9fce3682ddb

Tree: 31ae73c4f9a63387c4ab2079f8f74b27015e95da

Author: djg

Committer: GitHub

## 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

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

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