aboutsummaryrefslogtreecommitdiff
path: root/src/memusage.h
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2017-04-24 16:01:44 -0700
committerPieter Wuille <pieter.wuille@gmail.com>2017-04-24 16:06:15 -0700
commitc73af5416b66f09cec0eb106f5a10f9bb6ef9cb1 (patch)
tree333e7793d320544227392661d8760944e5acabc3 /src/memusage.h
parentfa1ac2881f2a751fba61e18c8be8645f3460b209 (diff)
parente6756ad33579766cd73973b7489ef2be9427a4c4 (diff)
downloadbitcoin-c73af5416b66f09cec0eb106f5a10f9bb6ef9cb1.tar.xz
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
Diffstat (limited to 'src/memusage.h')
-rw-r--r--src/memusage.h20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/memusage.h b/src/memusage.h
index 81e8702954..b69acafffd 100644
--- a/src/memusage.h
+++ b/src/memusage.h
@@ -12,6 +12,8 @@
#include <map>
#include <set>
#include <vector>
+#include <unordered_map>
+#include <unordered_set>
#include <boost/foreach.hpp>
#include <boost/unordered_set.hpp>
@@ -149,7 +151,7 @@ static inline size_t DynamicUsage(const std::shared_ptr<X>& p)
// Boost data structures
template<typename X>
-struct boost_unordered_node : private X
+struct unordered_node : private X
{
private:
void* ptr;
@@ -158,13 +160,25 @@ private:
template<typename X, typename Y>
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>
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());
}
}