diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..5659dfa757 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "parallel-hashmap"] + path = parallel-hashmap + url = https://github.com/greg7mdp/parallel-hashmap.git diff --git a/CMakeLists.txt b/CMakeLists.txt index b8fdee7d3a..1e446508e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,6 +61,8 @@ else() endif() endif() +include_directories(parallel-hashmap) + # --- optional re2c set(RE2C_MAJOR_VERSION 0) find_program(RE2C re2c) diff --git a/configure.py b/configure.py index c88daad508..b2abdfd50a 100755 --- a/configure.py +++ b/configure.py @@ -345,6 +345,7 @@ def search_system_path(file_name: str) -> Optional[str]: # type: ignore # Missi # Disable size_t -> int truncation warning. # We never have strings or arrays larger than 2**31. '/wd4267', + '/Iparallel-hashmap', '/DNOMINMAX', '/D_CRT_SECURE_NO_WARNINGS', '/D_HAS_EXCEPTIONS=0', '/DNINJA_PYTHON="%s"' % options.with_python] @@ -363,6 +364,7 @@ def search_system_path(file_name: str) -> Optional[str]: # type: ignore # Missi '-fno-exceptions', '-std=c++11', '-fvisibility=hidden', '-pipe', + '-Iparallel-hashmap', '-DNINJA_PYTHON="%s"' % options.with_python] if options.debug: cflags += ['-D_GLIBCXX_DEBUG', '-D_GLIBCXX_DEBUG_PEDANTIC'] diff --git a/parallel-hashmap b/parallel-hashmap new file mode 160000 index 0000000000..d88c5e1507 --- /dev/null +++ b/parallel-hashmap @@ -0,0 +1 @@ +Subproject commit d88c5e15079047777b418132ece5879e7c9aaa2b diff --git a/src/hash_map.h b/src/hash_map.h index 3f465338ac..5448a3fcef 100644 --- a/src/hash_map.h +++ b/src/hash_map.h @@ -17,6 +17,8 @@ #include #include +#include "parallel_hashmap/phmap.h" +#include "parallel_hashmap/phmap_utils.h" #include "string_piece.h" #include "util.h" @@ -53,8 +55,6 @@ unsigned int MurmurHash2(const void* key, size_t len) { return h; } -#include - namespace std { template<> struct hash { @@ -73,7 +73,7 @@ struct hash { /// mapping StringPiece => Foo*. template struct ExternalStringHashMap { - typedef std::unordered_map Type; + typedef phmap::flat_hash_map Type; }; #endif // NINJA_MAP_H_