Skip to content

SystemTools: Use unordered_map for path caches

By using a custom Fnva1 hash which hashes the lowercase chars and a custom equal comparator, we can use a std::unordered_map instead of the std::map for the file path caches. The Microsoft STL uses the same hash function, so the only difference is the tolower transformation of the chars.

This fixes a part of cmake/cmake#24113 (@jonesmz can you maybe post the speedup for your large project?)

This yields a nice speedup even for configuring CMake itself:

Old:
Benchmark 1: .\build-msvc-release\bin\cmake.exe -G Ninja -B build-perf -DCMAKE_BUILD_TYPE=Debug
  Time (mean ± σ):     18.526 s ±  0.162 s    [User: 0.001 s, System: 0.008 s]
  Range (min … max):   18.297 s … 18.880 s    10 runs

New:
Benchmark 1: .\build-msvc-release\bin\cmake.exe -G Ninja -B build-perf -DCMAKE_BUILD_TYPE=Debug
  Time (mean ± σ):     18.259 s ±  0.114 s    [User: 0.003 s, System: 0.004 s]
  Range (min … max):   18.100 s … 18.527 s    10 runs

Merge request reports

Loading