You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes a map is constructed when it is known that all keys are
unique (e. e. if keys are coming from another map or from a
sorted/deduplicated iterator). In this case we can make insertion
faster by skipping a check that a key already exists in the map.
`insert_unique_unchecked` is guaranteed to be memory-safe, but does
not guarantee anything beyoyd that: if inserted key is not unique,
`HashMap` can panic, loop forever, return incorrect entry etc.
Added simple benchmark. `insert_unique_unchecked` is about 30%
faster than `insert`. Your mileage may vary of course.
Similar PR was
[added to `indexmap` crate](indexmap-rs/indexmap#200)
and they asked to discuss the name of the operation with `hashbrown`
crate owners to come to the same naming convention (if `hashbrown`
is willing to have the same operation).
0 commit comments