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

Allow use of pre-hashed keys #122

Open
conradludgate opened this issue Feb 13, 2024 · 1 comment
Open

Allow use of pre-hashed keys #122

conradludgate opened this issue Feb 13, 2024 · 1 comment

Comments

@conradludgate
Copy link

As an optimisation, I want to be able to memoize a key-hash. My current solution is double-hashing with the first hash being key -> u64, then the second hash using a no-op hasher from u64 -> u64. However, this requires storing the hash twice in the hashmap.

I'm ok with such methods being unsafe if necessary, but the hashbrown equivalents are completely safe https://docs.rs/hashbrown/latest/hashbrown/hash_map/struct.RawEntryBuilder.html#method.from_key_hashed_nocheck

@jonhoo
Copy link
Owner

jonhoo commented Feb 17, 2024

Ah, so, they're safe only because hash <> key mismatches result only in correctness errors, not memory safety errors. I'm not sure whether the same would be true for the concurrent structure in flurry. I think we could probably expose a similar API though! PRs welcome :)

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

No branches or pull requests

2 participants