Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
SiarheiFedartsou committed Jul 10, 2024
1 parent 6d2fc45 commit 4b985c6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
7 changes: 0 additions & 7 deletions include/util/pool_allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,6 @@ class PoolAllocator
PoolAllocator &operator=(const PoolAllocator &) = default;
PoolAllocator(PoolAllocator &&) noexcept = default;
PoolAllocator &operator=(PoolAllocator &&) noexcept = default;

private:
static size_t get_next_power_of_two_exponent(size_t n)
{
BOOST_ASSERT(n > 0);
return (sizeof(size_t) * 8) - std::countl_zero(n - 1);
}
};

template <typename T, typename U>
Expand Down
7 changes: 5 additions & 2 deletions include/util/query_heap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define OSRM_UTIL_QUERY_HEAP_HPP

#include "util/pool_allocator.hpp"
#include <memory_resource>
#include <algorithm>
#include <boost/assert.hpp>
#include <boost/heap/d_ary_heap.hpp>
Expand Down Expand Up @@ -99,7 +100,7 @@ template <typename NodeID, typename Key> class MapStorage
template <typename NodeID, typename Key> class UnorderedMapStorage
{
public:
explicit UnorderedMapStorage(std::size_t) { nodes.rehash(1000); }
explicit UnorderedMapStorage(std::size_t) : poolResource_(std::pmr::new_delete_resource()), nodes(&poolResource_) { nodes.rehash(1000); }

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

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

private:
std::pmr::unsynchronized_pool_resource poolResource_;

template <typename K, typename V>
using UnorderedMap = std::
unordered_map<K, V/*, std::hash<K>, std::equal_to<K>, PoolAllocator<std::pair<const K, V>>*/>;
unordered_map<K, V, std::hash<K>, std::equal_to<K>, std::pmr::polymorphic_allocator<std::pair<const K, V>>>;

UnorderedMap<NodeID, Key> nodes;
};
Expand Down

0 comments on commit 4b985c6

Please sign in to comment.