martinus / robin-hood-hashing

Fast & memory efficient hashtable based on robin hood hashing for C++11/14/17/20
https://gitter.im/martinus/robin-hood-hashing
MIT License
1.5k stars 142 forks source link

Single lookup for try_emplace and insert_or_assign #116

Closed martinus closed 3 years ago

martinus commented 3 years ago

Found by @GilesBathgate who provided a POC in #114. Thanks!

Now try_emplace and isnert_or_assign don't require two lookups.

This implementation reuses the same insertion code for insert() and emplace(). Also fixes a bug for emplace() where a node was not destroyed when overflow exception occured.