diasurgical / devilutionX

Diablo build for modern operating systems
Other
8.08k stars 794 forks source link

Switch to a better hash map implementation #7314

Closed glebm closed 3 months ago

glebm commented 3 months ago

Switches to the excellent https://github.com/martinus/unordered_dense

Why?

The standard library hash map implementation in C++ (std::unordered_map) is notoriously slow and memory-hungry (this cannot be fixed due to stricter iterator requirements on std::unordered_map).

As we use maps in a few places, and are likely to use them more in the future (e.g. for dynamically mapping IDs from the TSV), so it makes sense to switch to a better implementation.

I picked this one in particular because it seems to be one of the most resource-effective and well-maintained implementations at the moment. Additionally, it support heterogenous lookup, which is not yet available in std::unordered_map on some of the platforms that we support.

The last commit in this PR also switches the few std::map instances to the new container. Those maps didn't need to be ordered.