Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove booster dependency #49

Merged
merged 2 commits into from
Sep 10, 2024
Merged

Remove booster dependency #49

merged 2 commits into from
Sep 10, 2024

Conversation

ericonr
Copy link
Member

@ericonr ericonr commented Sep 6, 2024

No description provided.

@ericonr
Copy link
Member Author

ericonr commented Sep 6, 2024

auto hash_t = hasher_t(x.first);
auto hash_u = hasher_u(x.second);

hash_u ^= hash_t + 0x9e3779b9 + (hash_u<<6) + (hash_u>>2);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where did this 0x9e3779b9 value comes from?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mind to mention it in the commit message? Magic numbers can easily become the reason for a misunderstanding or doubt, IMHO.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done >:)

util/decoders.cc Outdated Show resolved Hide resolved
This avoids depending on boost for anything, which simplifies the list
of dependencies.

Instead, we inline their hash_combine implementation, including the
magic constants, even if it isn't the best possible hash combinator [1].
The hasher class organization was taken from [2].

Since the hash of std::optional<unsigned> should be the same as the hash
of unsigned when it contains a value [3], and on libstdc++ and libc++
that hash is simply the identity function [4], it felt more appropriate
to use hash_u (the second member of the pair) as the seed, so it gets
some additional mixing.

[1] https://stackoverflow.com/q/35985960/9512804
[2] https://stackoverflow.com/a/20602159/9512804
[3] https://en.cppreference.com/w/cpp/utility/optional/hash
[4] https://tessil.github.io/2016/08/29/benchmark-hopscotch-map.html
@ericonr ericonr merged commit dc24c1a into master Sep 10, 2024
25 checks passed
@ericonr ericonr deleted the remove-booster branch September 10, 2024 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants