lnls-dig / uhal

HAL for LNLS's μTCA platform
https://lnls-dig.github.io/uhal/
GNU General Public License v3.0
0 stars 1 forks source link

Use std::string_view as std::unordered_map keys. #4

Closed ericonr closed 2 years ago

ericonr commented 2 years ago

The unordered_maps that were using <const char *> as keys were working by accident, thanks to the linker making it so the identifier strings had the same pointer, due to deduplication (this only works for access from the library itself). The ones that were using were working correctly, but for longer strings would lead to allocations for each map access. If we switch to , we avoid allocations but still get the automatic std::hash specialization.