From a55c03d1f4afe29734acea616709b9e89f33fba5 Mon Sep 17 00:00:00 2001 From: Justin Viiret Date: Thu, 22 Dec 2016 13:37:00 +1100 Subject: [PATCH] flat_set/map: back with small_vector --- src/util/ue2_containers.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/util/ue2_containers.h b/src/util/ue2_containers.h index c76dd88a..5af1ad8d 100644 --- a/src/util/ue2_containers.h +++ b/src/util/ue2_containers.h @@ -36,7 +36,8 @@ #include #include -#include +#include +#include #include #include #include @@ -94,8 +95,9 @@ private: template class flat_base { protected: - // Underlying storage is a sorted std::vector. - using storage_type = std::vector; + // Underlying storage is a small vector with local space for one element. + using storage_type = boost::container::small_vector; + using storage_alloc_type = typename storage_type::allocator_type; // Putting our storage and comparator in a tuple allows us to make use of // the empty base class optimization (if this STL implements it for @@ -103,7 +105,7 @@ protected: std::tuple storage; flat_base(const Compare &compare, const Allocator &alloc) - : storage(storage_type(alloc), compare) {} + : storage(storage_type(storage_alloc_type(alloc)), compare) {} }; } // namespace flat_detail @@ -341,8 +343,7 @@ public: // Free hash function. friend size_t hash_value(const flat_set &a) { - using boost::hash_value; - return hash_value(a.data); + return boost::hash_range(a.begin(), a.end()); } }; @@ -638,8 +639,7 @@ public: // Free hash function. friend size_t hash_value(const flat_map &a) { - using boost::hash_value; - return hash_value(a.data); + return boost::hash_range(a.begin(), a.end()); } };