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

std.hash_map: adding a rehash() method #19923

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mrjbq7
Copy link
Contributor

@mrjbq7 mrjbq7 commented May 10, 2024

Note: this resurrects the recently closed #17890.


This allows a highly fragmented HashMap to have tombstones removed as the values are all rehashed.

It would be nice to make this rehash() automatically, but that currently presents a challenge where it doesn't work with adapted contexts since the keys are not preserved in the map for re-hashing and the hash value is not stored currently, and the non-adapted contexts require a bit of additional book-keeping to check before calling rehash().

This is a partial fix for #17851, but requires the user to call rehash() periodically to get the benefit.

@mrjbq7 mrjbq7 force-pushed the rehash-again branch 2 times, most recently from 82a8478 to 24a1c54 Compare May 10, 2024 00:26
lib/std/hash_map.zig Outdated Show resolved Hide resolved
lib/std/hash_map.zig Outdated Show resolved Hide resolved
lib/std/hash_map.zig Outdated Show resolved Hide resolved
@mrjbq7
Copy link
Contributor Author

mrjbq7 commented May 10, 2024

@linusg thanks! fixed those 3 comments, and rebased on master again.

@mrjbq7 mrjbq7 force-pushed the rehash-again branch 2 times, most recently from ad2ebd0 to 51e0b86 Compare May 20, 2024 03:01
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.

None yet

2 participants