Skip to content

Commit

Permalink
Use std::unordered_{map,set} (C++11) instead of boost::unordered_{map…
Browse files Browse the repository at this point in the history
…,set}

Cherry-picked from: 246a02f
  • Loading branch information
practicalswift authored and xanimo committed Mar 29, 2024
1 parent e23ff6e commit 936b91f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 20 deletions.
17 changes: 0 additions & 17 deletions src/memusage.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
#include <unordered_map>
#include <unordered_set>

#include <boost/unordered_set.hpp>
#include <boost/unordered_map.hpp>

namespace memusage
{

Expand Down Expand Up @@ -147,27 +144,13 @@ static inline size_t DynamicUsage(const std::shared_ptr<X>& p)
return p ? MallocUsage(sizeof(X)) + MallocUsage(sizeof(stl_shared_counter)) : 0;
}

// Boost data structures

template<typename X>
struct unordered_node : private X
{
private:
void* ptr;
};

template<typename X, typename Y>
static inline size_t DynamicUsage(const boost::unordered_set<X, Y>& s)
{
return MallocUsage(sizeof(unordered_node<X>)) * s.size() + MallocUsage(sizeof(void*) * s.bucket_count());
}

template<typename X, typename Y, typename Z>
static inline size_t DynamicUsage(const boost::unordered_map<X, Y, Z>& m)
{
return MallocUsage(sizeof(unordered_node<std::pair<const X, Y> >)) * m.size() + MallocUsage(sizeof(void*) * m.bucket_count());
}

template<typename X, typename Y>
static inline size_t DynamicUsage(const std::unordered_set<X, Y>& s)
{
Expand Down
4 changes: 1 addition & 3 deletions src/validation.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@

#include <atomic>

#include <boost/unordered_map.hpp>

class CBlockIndex;
class CBlockTreeDB;
class CBloomFilter;
Expand Down Expand Up @@ -165,7 +163,7 @@ struct BlockHasher
extern CScript COINBASE_FLAGS;
extern CCriticalSection cs_main;
extern CTxMemPool mempool;
typedef boost::unordered_map<uint256, CBlockIndex*, BlockHasher> BlockMap;
typedef std::unordered_map<uint256, CBlockIndex*, BlockHasher> BlockMap;
extern BlockMap mapBlockIndex;
extern uint64_t nLastBlockTx;
extern uint64_t nLastBlockSize;
Expand Down

0 comments on commit 936b91f

Please sign in to comment.