-
-
Notifications
You must be signed in to change notification settings - Fork 249
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
Avoid Memory Reallocations in flat_hash_map clear for Trivial Classes #205
Comments
Thanks @linjiahao962889027, this is a good suggestion, I'll look into it. |
Hey @linjiahao962889027 , this should fix your issue, please let me know if you see any problem. |
greg7mdp
added a commit
that referenced
this issue
Sep 4, 2023
|
This was referenced Mar 29, 2024
thanks it resolve my issue
|
Excellent, thanks for letting me know! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description:
When both the Key and Value types are trivial classes, I suggest modifying the behavior of clear in flat_hash_map to avoid releasing memory, similar to the behavior of std::vector. The current reallocation during clear impacts performance due to the second allocation, especially for trivial types where memory deallocation isn't necessary. This change would align the behavior with other standard containers, providing better performance for scenarios where frequent clearing is required.
The text was updated successfully, but these errors were encountered: