File tree Expand file tree Collapse file tree 6 files changed +2094
-2066
lines changed
Expand file tree Collapse file tree 6 files changed +2094
-2066
lines changed Original file line number Diff line number Diff line change 1+ [submodule "third-party/parallel-hashmap "]
2+ path = third-party/parallel-hashmap
3+ url = https://github.com/greg7mdp/parallel-hashmap.git
Original file line number Diff line number Diff line change @@ -19,17 +19,21 @@ else ()
1919 set (CMAKE_CXX_STANDARD 17)
2020endif ()
2121
22+ message (STATUS "CMAKE_SYSTEM_PROCESSOR:${CMAKE_SYSTEM_PROCESSOR} " )
23+
2224# Detect the architecture
2325if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|AMD64|i386|i686)$" )
2426 set (ARCH_X86 TRUE )
25- elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm|aarch64)$" )
27+ elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm|aarch64|arm64)$" )
28+ message (STATUS "By default, arm enables NEON for simd optimization" )
2629 set (ARCH_ARM TRUE )
2730else ()
2831 set (ARCH_UNKNOWN TRUE )
2932endif ()
3033
3134# Define options for SIMD instruction sets
3235option (USE_SIMD "Enable SIMD instructions" ON )
36+ option (USE_FLAG_HASH_MAP "Enable FlatHashMap" ON )
3337
3438# These options are only relevant if SIMD is enabled and the architecture is x86
3539if ((NOT USE_AVX2 AND (USE_SIMD AND ARCH_X86)) OR USE_SSE4_2)
@@ -67,6 +71,12 @@ endif ()
6771
6872add_library (ejson ${PROJECT_SOURCE_DIR} /src/ejson/jobject.cc ${PROJECT_SOURCE_DIR} /src/ejson/parser.cc ${PROJECT_SOURCE_DIR} /src/ejson/base64.cc)
6973
74+ if (USE_FLAG_HASH_MAP)
75+ message (STATUS "Use FlatHashMap" )
76+ add_definitions (-DUSE_FLAT_HASH_MAP)
77+ target_include_directories (ejson PUBLIC ${PROJECT_SOURCE_DIR} /third-party/parallel-hashmap)
78+ endif ()
79+
7080if (USE_SIMD)
7181 message (STATUS "Use SIMD Flags:${SIMD_FLAGS} " )
7282 target_compile_options (ejson PRIVATE ${SIMD_FLAGS} )
Original file line number Diff line number Diff line change 1515#include < unordered_set>
1616#include < vector>
1717
18+ #ifdef USE_FLAT_HASH_MAP
19+
20+ #include < parallel_hashmap/phmap.h>
21+
22+ #endif
23+
1824#include " autogen.h"
1925#include " noncopyable.h"
2026#include " third_part.h"
@@ -35,7 +41,11 @@ using bool_t = bool;
3541using double_t = double ;
3642using str_t = string_view;
3743using list_t = std::vector<JObject>;
38- using dict_t = std::unordered_map<str_t , JObject>;
44+ #ifdef USE_FLAT_HASH_MAP
45+ using dict_t = phmap::flat_hash_map<str_t , JObject>;
46+ #else
47+ using dict_t = std::map<str_t , JObject>;
48+ #endif
3949
4050#define EJSON_TYPE_IS (typea, typeb ) std::is_same<typea, typeb>::value
4151
You can’t perform that action at this time.
0 commit comments