|
11 | 11 | #include <memory_resource>
|
12 | 12 | #include <utility>
|
13 | 13 |
|
14 |
| -#include <parallel_hashmap/phmap.h> |
| 14 | +#include <boost/unordered/unordered_flat_map.hpp> |
15 | 15 |
|
16 | 16 | #include <dplx/cncr/utils.hpp>
|
17 | 17 | #include <dplx/cncr/uuid.hpp>
|
18 | 18 |
|
| 19 | +#include <dplx/dp/detail/workaround.hpp> |
19 | 20 | #include <dplx/dp/fwd.hpp>
|
20 | 21 |
|
21 | 22 | namespace dplx::dp::detail
|
@@ -121,6 +122,13 @@ class unique_erased_state_ptr
|
121 | 122 | , mDelete(std::exchange(other.mDelete, nullptr))
|
122 | 123 | {
|
123 | 124 | }
|
| 125 | +#if DPLX_DP_WORKAROUND_ISSUE_LIBSTDCPP_108952 |
| 126 | + constexpr unique_erased_state_ptr(unique_erased_state_ptr &other) noexcept |
| 127 | + : mObj(std::exchange(other.mObj, nullptr)) |
| 128 | + , mDelete(std::exchange(other.mDelete, nullptr)) |
| 129 | + { |
| 130 | + } |
| 131 | +#endif |
124 | 132 | constexpr auto operator=(unique_erased_state_ptr &&other) noexcept
|
125 | 133 | -> unique_erased_state_ptr &
|
126 | 134 | {
|
@@ -195,7 +203,7 @@ namespace dplx::dp::detail
|
195 | 203 | {
|
196 | 204 |
|
197 | 205 | template <typename Key, typename T>
|
198 |
| -using flat_hash_map = phmap::flat_hash_map< |
| 206 | +using flat_hash_map = boost::unordered_flat_map< |
199 | 207 | Key,
|
200 | 208 | T,
|
201 | 209 | std::hash<Key>,
|
@@ -278,14 +286,14 @@ class state_store
|
278 | 286 | auto emplace(state_key<StateT> const &key, Args &&...args)
|
279 | 287 | -> std::pair<StateT *, bool>
|
280 | 288 | {
|
281 |
| - auto const h = mImpl.hash(key.value); |
282 |
| - if (auto it = mImpl.find(key.value, h); it != mImpl.end()) |
| 289 | + auto hint = mImpl.find(key.value); |
| 290 | + if (hint != mImpl.end()) |
283 | 291 | {
|
284 | 292 | // this way, we don't need to allocate if key already has a value
|
285 |
| - return {it->second.template get<StateT>(), false}; |
| 293 | + return {hint->second.template get<StateT>(), false}; |
286 | 294 | }
|
287 |
| - auto [it, emplaced] = mImpl.emplace_with_hash( |
288 |
| - h, key.value, |
| 295 | + auto it = mImpl.emplace_hint( |
| 296 | + hint, key.value, |
289 | 297 | detail::allocate_state<StateT, allocator_type>(
|
290 | 298 | mImpl.get_allocator(), static_cast<Args &&>(args)...));
|
291 | 299 | return {it->second.template get<StateT>(), true};
|
@@ -401,15 +409,13 @@ class link_store
|
401 | 409 | template <state_link T>
|
402 | 410 | auto replace(state_link_key<T> const &key, T value) -> T
|
403 | 411 | {
|
404 |
| - auto const h = mImpl.hash(key.value); |
405 |
| - auto it = mImpl.find(key.value, h); |
| 412 | + auto it = mImpl.find(key.value); |
406 | 413 | if (it == mImpl.end())
|
407 | 414 | {
|
408 | 415 | if (value != T{})
|
409 | 416 | {
|
410 |
| - mImpl.emplace_with_hash( |
411 |
| - h, key.value, |
412 |
| - detail::erasure_cast<erased_type, T>(value)); |
| 417 | + mImpl.emplace_hint(it, key.value, |
| 418 | + detail::erasure_cast<erased_type, T>(value)); |
413 | 419 | }
|
414 | 420 | return T{};
|
415 | 421 | }
|
|
0 commit comments