From 344a2c4122db5ae309e6dddc99b3e136fd307238 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Fri, 21 Apr 2017 05:26:23 -0700 Subject: [PATCH 1/2] Add support for std::unordered_{map,set} to memusage.h --- src/memusage.h | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/memusage.h b/src/memusage.h index 81e870295..b69acafff 100644 --- a/src/memusage.h +++ b/src/memusage.h @@ -12,6 +12,8 @@ #include #include #include +#include +#include #include #include @@ -149,7 +151,7 @@ static inline size_t DynamicUsage(const std::shared_ptr& p) // Boost data structures template -struct boost_unordered_node : private X +struct unordered_node : private X { private: void* ptr; @@ -158,13 +160,25 @@ private: template static inline size_t DynamicUsage(const boost::unordered_set& s) { - return MallocUsage(sizeof(boost_unordered_node)) * s.size() + MallocUsage(sizeof(void*) * s.bucket_count()); + return MallocUsage(sizeof(unordered_node)) * s.size() + MallocUsage(sizeof(void*) * s.bucket_count()); } template static inline size_t DynamicUsage(const boost::unordered_map& m) { - return MallocUsage(sizeof(boost_unordered_node >)) * m.size() + MallocUsage(sizeof(void*) * m.bucket_count()); + return MallocUsage(sizeof(unordered_node >)) * m.size() + MallocUsage(sizeof(void*) * m.bucket_count()); +} + +template +static inline size_t DynamicUsage(const std::unordered_set& s) +{ + return MallocUsage(sizeof(unordered_node)) * s.size() + MallocUsage(sizeof(void*) * s.bucket_count()); +} + +template +static inline size_t DynamicUsage(const std::unordered_map& m) +{ + return MallocUsage(sizeof(unordered_node >)) * m.size() + MallocUsage(sizeof(void*) * m.bucket_count()); } } From e6756ad33579766cd73973b7489ef2be9427a4c4 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Fri, 21 Apr 2017 05:26:40 -0700 Subject: [PATCH 2/2] Switch CCoinsMap from boost to std unordered_map --- src/coins.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coins.h b/src/coins.h index 0cb8519df..065bae56e 100644 --- a/src/coins.h +++ b/src/coins.h @@ -18,7 +18,7 @@ #include #include -#include +#include /** * Pruned version of CTransaction: only retains metadata and unspent transaction outputs @@ -280,7 +280,7 @@ struct CCoinsCacheEntry CCoinsCacheEntry() : coins(), flags(0) {} }; -typedef boost::unordered_map CCoinsMap; +typedef std::unordered_map CCoinsMap; /** Cursor for iterating over CoinsView state */ class CCoinsViewCursor