-
Notifications
You must be signed in to change notification settings - Fork 13.3k
std: Add performance warnings to HashMap::get_disjoint_mut #139307
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
base: master
Are you sure you want to change the base?
Conversation
To be honest I don't understand why, why not just sort the list of hashes and check neighbours (n log n)? |
I'm not sure. I think what you said seems reasonable.We can wait for the members of libs to discuss it. Maybe we can change the implementation. |
So, we can't do it with the hashes due to collisions, and However, I think it would be possible to do everything up to getting the raw pointer of each element to return, then use this technique there. The performance is worse in the case of an overlap, but I think that is irrelevant since it panics in that case. But honestly it's probably not worth it, most use cases are probably 2 or 3 keys where the perf would probably even be worse. So I would go ahead with documenting it. |
Actually |
Signed-off-by: xizheyin <[email protected]>
r? libs |
Co-authored-by: Jonas Böttiger <[email protected]>
Closes #139296
The
get_disjoint_mut
inHashMap
also performs a complexity O(n^2) check. So we need to be reminded of that as well.https://github.com./rust-lang/hashbrown/blob/b5b0655a37e156f9798ac8dd7e970d4adba9bf90/src/raw/mod.rs#L1216-L1220