Skip to content

Conversation

@martinus
Copy link
Owner

Fixes #98. This changes the behavior of unordered_dense:

  • Now an initial map allocates. So creating & never using a bunch of maps will have more overhead - That's not something I optimize for though.
  • operator[], or try_emplace doesn't increase size when the element is found. Basically I had to shift an if to another place, so performance wise there shouldn't be much of a difference. Maybe it's even faster.

…ert occurs

This required a few refactorings. Most importantly, a newly constructed map now allocates
an empty bucket array. This might cause slowdowns when you create lots of maps without
ever inserting anything.

The advantage is that try_emplace should have the same speed, or even be a bit faster; especially
when no insertion happens.
@martinus martinus merged commit 335e66c into main Dec 17, 2023
@martinus martinus deleted the 2023-12-dont-resize-in-emplace-when-not-necessary branch December 17, 2023 08:00
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.

Race condition when using [] operator on map when accessing a key that is known to already exist

2 participants