Skip to content

Commit

Permalink
use parallel-hashmap
Browse files Browse the repository at this point in the history
  • Loading branch information
atetubou committed Jun 13, 2024
1 parent 0b4b43a commit 8dbafd0
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 3 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
image: fedora:40
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install dependencies
run: dnf install -y ninja-build cmake gtest-devel re2c clang util-linux
- name: Linting
Expand Down Expand Up @@ -42,6 +44,8 @@ jobs:
image: rockylinux:8
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: codespell-project/actions-codespell@master
with:
ignore_words_list: fo,wee,addin,notin
Expand Down Expand Up @@ -104,6 +108,8 @@ jobs:
image: ubuntu:20.04
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install dependencies
run: |
apt update
Expand Down Expand Up @@ -160,6 +166,8 @@ jobs:
image: ['ubuntu:20.04', 'ubuntu:22.04', 'ubuntu:24.04']
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install dependencies
run: |
apt update
Expand All @@ -176,6 +184,8 @@ jobs:
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Build
uses: uraimo/run-on-arch-action@v2
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install dependencies
run: brew install re2c p7zip cmake
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install dependencies
run: choco install re2c
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "parallel-hashmap"]
path = parallel-hashmap
url = https://github.com/greg7mdp/parallel-hashmap.git
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ else()
endif()
endif()

include_directories(parallel-hashmap)

# --- optional re2c
set(RE2C_MAJOR_VERSION 0)
find_program(RE2C re2c)
Expand Down
2 changes: 2 additions & 0 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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']
Expand Down
1 change: 1 addition & 0 deletions parallel-hashmap
Submodule parallel-hashmap added at d88c5e
6 changes: 3 additions & 3 deletions src/hash_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

#include <algorithm>
#include <string.h>
#include "parallel_hashmap/phmap.h"
#include "parallel_hashmap/phmap_utils.h"
#include "string_piece.h"
#include "util.h"

Expand Down Expand Up @@ -53,8 +55,6 @@ unsigned int MurmurHash2(const void* key, size_t len) {
return h;
}

#include <unordered_map>

namespace std {
template<>
struct hash<StringPiece> {
Expand All @@ -73,7 +73,7 @@ struct hash<StringPiece> {
/// mapping StringPiece => Foo*.
template<typename V>
struct ExternalStringHashMap {
typedef std::unordered_map<StringPiece, V> Type;
typedef phmap::flat_hash_map<StringPiece, V> Type;
};

#endif // NINJA_MAP_H_

0 comments on commit 8dbafd0

Please sign in to comment.