-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
map: make DenseArray::has_index not assume string keys #7284
Conversation
Add separate `is_deleted` array - this is only allocated the first time a key is deleted. Also set array cap in test.
@@ -484,7 +497,6 @@ pub fn (mut m map) delete(key string) { | |||
if m.key_values.deletes >= (m.key_values.len >> 1) { | |||
m.key_values.zeros_to_end() | |||
m.rehash() | |||
m.key_values.deletes = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: zeros_to_end
already does this, so this was redundant.
LGTM, but I think we need better tests (fuzzing) to ensure that we are not introducing bugs. We need something like https://github.com/ka-weihe/hashmap-v/blob/master/monkeytest.v, but better. I used to run that for multiple hours in multiple threads with |
@ka-weihe OK, thanks. |
Part of #6991.
Add separate
is_deleted
array - this is only allocated the first time a key is deleted. This is allocated separately from thedata
array for better performance when there are no deleted elements (a common case).Also set array
cap
in test.