Celestia icon indicating copy to clipboard operation
Celestia copied to clipboard

Use unordered_dense for hash tables

Open ajtribick opened this issue 1 year ago • 2 comments

The standard library unordered_map has various issues that make it slow. Might be worth investigating https://github.com/martinus/unordered_dense as a replacement.

(It may also be worth considering Boost flat_map for the case where we actually need a sorted map - e.g. for prefix searching in the name manager)

ajtribick avatar Jan 13 '24 00:01 ajtribick

We don't use unordered_map in any performance critical code afaik.

375gnu avatar Jan 13 '24 09:01 375gnu

The other advantage of unordered_dense is that it offers the possibility for heterogeneous lookups (e.g. use a string_view to do lookups in a hash table with string keys), which isn't offered by std::unordered_map until C++20.

ajtribick avatar Jan 20 '24 07:01 ajtribick