# stage1 HashMap: store hash & do robin hood hashing · gitcafe/zig

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

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

Visibility: public

Requested revision: df2c27eb486383a291dfe1db3dfda51f830f59c5

Requested commit: df2c27eb486383a291dfe1db3dfda51f830f59c5

Commit: df2c27eb486383a291dfe1db3dfda51f830f59c5

Tree: 9af0034e86f206850d3ec5d1fa66582543c490b5

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
stage1 HashMap: store hash & do robin hood hashing

This adds these two fields to a HashMap Entry:

uint32_t hash
uint32_t distance_from_start_index

Compared to master branch, standard library tests compiled 8.4% faster
and took negligible (0.001%) more memory to complete. The amount of
memory used is still down from before 8b82c4010480 which moved indexes
to be stored separately from entries.

So, it turns out, keeping robin hood hashing plus separating indexes
did result in a performance improvement. What happened previously is
that the gains from separating indexes balanced out the losses from
removing robin hood hashing, resulting in a wash.

This also serves as an inspiration for adding a benchmark to
std.AutoHashMap and improving the implementation.

```

## Parents

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

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