Skip to content

Commit c73af54

Browse files
committed
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
2 parents fa1ac28 + e6756ad commit c73af54

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

src/coins.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <stdint.h>
1919

2020
#include <boost/foreach.hpp>
21-
#include <boost/unordered_map.hpp>
21+
#include <unordered_map>
2222

2323
/**
2424
* Pruned version of CTransaction: only retains metadata and unspent transaction outputs
@@ -280,7 +280,7 @@ struct CCoinsCacheEntry
280280
CCoinsCacheEntry() : coins(), flags(0) {}
281281
};
282282

283-
typedef boost::unordered_map<uint256, CCoinsCacheEntry, SaltedTxidHasher> CCoinsMap;
283+
typedef std::unordered_map<uint256, CCoinsCacheEntry, SaltedTxidHasher> CCoinsMap;
284284

285285
/** Cursor for iterating over CoinsView state */
286286
class CCoinsViewCursor

src/memusage.h

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#include <map>
1313
#include <set>
1414
#include <vector>
15+
#include <unordered_map>
16+
#include <unordered_set>
1517

1618
#include <boost/foreach.hpp>
1719
#include <boost/unordered_set.hpp>
@@ -149,7 +151,7 @@ static inline size_t DynamicUsage(const std::shared_ptr<X>& p)
149151
// Boost data structures
150152

151153
template<typename X>
152-
struct boost_unordered_node : private X
154+
struct unordered_node : private X
153155
{
154156
private:
155157
void* ptr;
@@ -158,13 +160,25 @@ struct boost_unordered_node : private X
158160
template<typename X, typename Y>
159161
static inline size_t DynamicUsage(const boost::unordered_set<X, Y>& s)
160162
{
161-
return MallocUsage(sizeof(boost_unordered_node<X>)) * s.size() + MallocUsage(sizeof(void*) * s.bucket_count());
163+
return MallocUsage(sizeof(unordered_node<X>)) * s.size() + MallocUsage(sizeof(void*) * s.bucket_count());
162164
}
163165

164166
template<typename X, typename Y, typename Z>
165167
static inline size_t DynamicUsage(const boost::unordered_map<X, Y, Z>& m)
166168
{
167-
return MallocUsage(sizeof(boost_unordered_node<std::pair<const X, Y> >)) * m.size() + MallocUsage(sizeof(void*) * m.bucket_count());
169+
return MallocUsage(sizeof(unordered_node<std::pair<const X, Y> >)) * m.size() + MallocUsage(sizeof(void*) * m.bucket_count());
170+
}
171+
172+
template<typename X, typename Y>
173+
static inline size_t DynamicUsage(const std::unordered_set<X, Y>& s)
174+
{
175+
return MallocUsage(sizeof(unordered_node<X>)) * s.size() + MallocUsage(sizeof(void*) * s.bucket_count());
176+
}
177+
178+
template<typename X, typename Y, typename Z>
179+
static inline size_t DynamicUsage(const std::unordered_map<X, Y, Z>& m)
180+
{
181+
return MallocUsage(sizeof(unordered_node<std::pair<const X, Y> >)) * m.size() + MallocUsage(sizeof(void*) * m.bucket_count());
168182
}
169183

170184
}

0 commit comments

Comments
 (0)