From afa96b7c12b6ce29ecb7abd3cf778c3e53d0265d Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Mon, 24 Apr 2017 16:01:44 -0700 Subject: [PATCH] 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 --- src/coins.h | 4 ++-- src/memusage.h | 20 +++++++++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/coins.h b/src/coins.h index 6110c1937..444f53963 100644 --- a/src/coins.h +++ b/src/coins.h @@ -17,7 +17,7 @@ #include #include -#include +#include /** * Pruned version of CTransaction: only retains metadata and unspent transaction outputs @@ -302,7 +302,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 diff --git a/src/memusage.h b/src/memusage.h index 49760e64c..0d2436ec6 100644 --- a/src/memusage.h +++ b/src/memusage.h @@ -10,6 +10,8 @@ #include #include #include +#include +#include #include #include @@ -109,7 +111,7 @@ static inline size_t IncrementalDynamicUsage(const std::map& m) // Boost data structures template -struct boost_unordered_node : private X +struct unordered_node : private X { private: void* ptr; @@ -118,13 +120,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()); } }