Skip to content

Commit 4b985c6

Browse files
wip
1 parent 6d2fc45 commit 4b985c6

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

Diff for: include/util/pool_allocator.hpp

-7
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,6 @@ class PoolAllocator
130130
PoolAllocator &operator=(const PoolAllocator &) = default;
131131
PoolAllocator(PoolAllocator &&) noexcept = default;
132132
PoolAllocator &operator=(PoolAllocator &&) noexcept = default;
133-
134-
private:
135-
static size_t get_next_power_of_two_exponent(size_t n)
136-
{
137-
BOOST_ASSERT(n > 0);
138-
return (sizeof(size_t) * 8) - std::countl_zero(n - 1);
139-
}
140133
};
141134

142135
template <typename T, typename U>

Diff for: include/util/query_heap.hpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define OSRM_UTIL_QUERY_HEAP_HPP
33

44
#include "util/pool_allocator.hpp"
5+
#include <memory_resource>
56
#include <algorithm>
67
#include <boost/assert.hpp>
78
#include <boost/heap/d_ary_heap.hpp>
@@ -99,7 +100,7 @@ template <typename NodeID, typename Key> class MapStorage
99100
template <typename NodeID, typename Key> class UnorderedMapStorage
100101
{
101102
public:
102-
explicit UnorderedMapStorage(std::size_t) { nodes.rehash(1000); }
103+
explicit UnorderedMapStorage(std::size_t) : poolResource_(std::pmr::new_delete_resource()), nodes(&poolResource_) { nodes.rehash(1000); }
103104

104105
Key &operator[](const NodeID node) { return nodes[node]; }
105106

@@ -122,9 +123,11 @@ template <typename NodeID, typename Key> class UnorderedMapStorage
122123
void Clear() { nodes.clear(); }
123124

124125
private:
126+
std::pmr::unsynchronized_pool_resource poolResource_;
127+
125128
template <typename K, typename V>
126129
using UnorderedMap = std::
127-
unordered_map<K, V/*, std::hash<K>, std::equal_to<K>, PoolAllocator<std::pair<const K, V>>*/>;
130+
unordered_map<K, V, std::hash<K>, std::equal_to<K>, std::pmr::polymorphic_allocator<std::pair<const K, V>>>;
128131

129132
UnorderedMap<NodeID, Key> nodes;
130133
};

0 commit comments

Comments
 (0)