Merge #10249: Switch CCoinsMap from boost to std unordered_map
e6756ad Switch CCoinsMap from boost to std unordered_map (Pieter Wuille) 344a2c4 Add support for std::unordered_{map,set} to memusage.h (Pieter Wuille) Tree-SHA512: 51288301e7c0f29ffac8c59f4cc73ddc36b7abeb764009da6543f2eaeeb9f89bd47dde48131a7e0aefad8f7cb0b74b2f33b8be052c8e8a718339c3e6bb963447
This commit is contained in:
parent
8ed6722196
commit
afa96b7c12
@ -17,7 +17,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
#include <boost/unordered_map.hpp>
|
#include <unordered_map>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pruned version of CTransaction: only retains metadata and unspent transaction outputs
|
* Pruned version of CTransaction: only retains metadata and unspent transaction outputs
|
||||||
@ -302,7 +302,7 @@ struct CCoinsCacheEntry
|
|||||||
CCoinsCacheEntry() : coins(), flags(0) {}
|
CCoinsCacheEntry() : coins(), flags(0) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef boost::unordered_map<uint256, CCoinsCacheEntry, SaltedTxidHasher> CCoinsMap;
|
typedef std::unordered_map<uint256, CCoinsCacheEntry, SaltedTxidHasher> CCoinsMap;
|
||||||
|
|
||||||
/** Cursor for iterating over CoinsView state */
|
/** Cursor for iterating over CoinsView state */
|
||||||
class CCoinsViewCursor
|
class CCoinsViewCursor
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <unordered_set>
|
||||||
|
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
#include <boost/unordered_set.hpp>
|
#include <boost/unordered_set.hpp>
|
||||||
@ -109,7 +111,7 @@ static inline size_t IncrementalDynamicUsage(const std::map<X, Y, Z>& m)
|
|||||||
// Boost data structures
|
// Boost data structures
|
||||||
|
|
||||||
template<typename X>
|
template<typename X>
|
||||||
struct boost_unordered_node : private X
|
struct unordered_node : private X
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
void* ptr;
|
void* ptr;
|
||||||
@ -118,13 +120,25 @@ private:
|
|||||||
template<typename X, typename Y>
|
template<typename X, typename Y>
|
||||||
static inline size_t DynamicUsage(const boost::unordered_set<X, Y>& s)
|
static inline size_t DynamicUsage(const boost::unordered_set<X, Y>& s)
|
||||||
{
|
{
|
||||||
return MallocUsage(sizeof(boost_unordered_node<X>)) * s.size() + MallocUsage(sizeof(void*) * s.bucket_count());
|
return MallocUsage(sizeof(unordered_node<X>)) * s.size() + MallocUsage(sizeof(void*) * s.bucket_count());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename X, typename Y, typename Z>
|
template<typename X, typename Y, typename Z>
|
||||||
static inline size_t DynamicUsage(const boost::unordered_map<X, Y, Z>& m)
|
static inline size_t DynamicUsage(const boost::unordered_map<X, Y, Z>& m)
|
||||||
{
|
{
|
||||||
return MallocUsage(sizeof(boost_unordered_node<std::pair<const X, Y> >)) * m.size() + MallocUsage(sizeof(void*) * m.bucket_count());
|
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)
|
||||||
|
{
|
||||||
|
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 std::unordered_map<X, Y, Z>& m)
|
||||||
|
{
|
||||||
|
return MallocUsage(sizeof(unordered_node<std::pair<const X, Y> >)) * m.size() + MallocUsage(sizeof(void*) * m.bucket_count());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user