Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Unified Diff: base/containers/hash_tables.h

Issue 2572593002: [counting_allocator] Chrome changes.
Patch Set: Surface max_size; instrument flat_set. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/containers/flat_set.h ('k') | base/trace_event/heap_profiler_allocation_register.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/containers/hash_tables.h
diff --git a/base/containers/hash_tables.h b/base/containers/hash_tables.h
index 8da7b6726852d2c762c6c2ff9ad5035d7450e5ba..428334fc8a0b0ca87d5c89052d1e39132944ea11 100644
--- a/base/containers/hash_tables.h
+++ b/base/containers/hash_tables.h
@@ -40,12 +40,19 @@ struct hash<std::pair<Type1, Type2>> {
namespace base {
+#if defined(_LIBCPP_COUNTING_ALLOCATOR)
+#define HASH_CONTAINER_ALLOCATOR(group, type...) \
+ std::counting_allocator<type, std::allocation_group::group>
+#else
+#define HASH_CONTAINER_ALLOCATOR(group, type...) std::allocator<type>
+#endif
+
// Use std::unordered_map instead.
template <class Key,
class T,
class Hash = BASE_HASH_NAMESPACE::hash<Key>,
class Pred = std::equal_to<Key>,
- class Alloc = std::allocator<std::pair<const Key, T>>>
+ class Alloc = HASH_CONTAINER_ALLOCATOR(unordered_map, std::pair<const Key, T>)>
using hash_map = std::unordered_map<Key, T, Hash, Pred, Alloc>;
// Use std::unordered_multimap instead.
@@ -53,23 +60,25 @@ template <class Key,
class T,
class Hash = BASE_HASH_NAMESPACE::hash<Key>,
class Pred = std::equal_to<Key>,
- class Alloc = std::allocator<std::pair<const Key, T>>>
+ class Alloc = HASH_CONTAINER_ALLOCATOR(unordered_multimap, std::pair<const Key, T>)>
using hash_multimap = std::unordered_multimap<Key, T, Hash, Pred, Alloc>;
// Use std::unordered_multiset instead.
template <class Key,
class Hash = BASE_HASH_NAMESPACE::hash<Key>,
class Pred = std::equal_to<Key>,
- class Alloc = std::allocator<Key>>
+ class Alloc = HASH_CONTAINER_ALLOCATOR(unordered_multiset, Key)>
using hash_multiset = std::unordered_multiset<Key, Hash, Pred, Alloc>;
// Use std::unordered_set instead.
template <class Key,
class Hash = BASE_HASH_NAMESPACE::hash<Key>,
class Pred = std::equal_to<Key>,
- class Alloc = std::allocator<Key>>
+ class Alloc = HASH_CONTAINER_ALLOCATOR(unordered_set, Key)>
using hash_set = std::unordered_set<Key, Hash, Pred, Alloc>;
+#undef HASH_CONTAINER_ALLOCATOR
+
} // namespace base
#endif // BASE_CONTAINERS_HASH_TABLES_H_
« no previous file with comments | « base/containers/flat_set.h ('k') | base/trace_event/heap_profiler_allocation_register.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698