indexmap-rs / indexmap

A hash table with consistent order and fast iteration; access items by key or sequence index
https://docs.rs/indexmap/
Other
1.67k stars 150 forks source link

Avoid hashing for single-entry maps #316

Closed cuviper closed 6 months ago

cuviper commented 6 months ago

We already avoid hashing for get/remove on empty maps, but we can also do this for single-entry maps. Even with a cheap hash function, a single equality check ought to be faster than any hash table lookup.