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

Unified Diff: include/unordered_map

Issue 2574553002: [counting-allocator] macOS buildtools/third_party/libc++/trunk/ changes.
Patch Set: Created 4 years 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 | « include/string ('k') | include/unordered_set » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/unordered_map
diff --git a/include/unordered_map b/include/unordered_map
index 3c774d4094e0e0c4dad4eb6d631c288660bd8145..2a5a718555609bef435d56a35b137c163844fc2d 100644
--- a/include/unordered_map
+++ b/include/unordered_map
@@ -543,14 +543,12 @@ private:
__hash_map_node_destructor& operator=(const __hash_map_node_destructor&);
public:
- bool __first_constructed;
- bool __second_constructed;
+ bool __constructed;
_LIBCPP_INLINE_VISIBILITY
explicit __hash_map_node_destructor(allocator_type& __na) _NOEXCEPT
: __na_(__na),
- __first_constructed(false),
- __second_constructed(false)
+ __constructed(false)
{}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
@@ -558,8 +556,7 @@ public:
__hash_map_node_destructor(__hash_node_destructor<allocator_type>&& __x)
_NOEXCEPT
: __na_(__x.__na_),
- __first_constructed(__x.__value_constructed),
- __second_constructed(__x.__value_constructed)
+ __constructed(__x.__value_constructed)
{
__x.__value_constructed = false;
}
@@ -567,8 +564,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
__hash_map_node_destructor(const __hash_node_destructor<allocator_type>& __x)
: __na_(__x.__na_),
- __first_constructed(__x.__value_constructed),
- __second_constructed(__x.__value_constructed)
+ __constructed(__x.__value_constructed)
{
const_cast<bool&>(__x.__value_constructed) = false;
}
@@ -577,10 +573,8 @@ public:
_LIBCPP_INLINE_VISIBILITY
void operator()(pointer __p) _NOEXCEPT
{
- if (__second_constructed)
- __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__cc.second));
- if (__first_constructed)
- __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__cc.first));
+ if (__constructed)
+ __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_));
if (__p)
__alloc_traits::deallocate(__na_, __p, 1);
}
@@ -768,7 +762,7 @@ public:
};
template <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>,
- class _Alloc = allocator<pair<const _Key, _Tp> > >
+ class _Alloc = counting_allocator<pair<const _Key, _Tp>, allocation_group::unordered_map > >
class _LIBCPP_TYPE_VIS_ONLY unordered_map
{
public:
@@ -789,7 +783,7 @@ private:
typedef __hash_value_type<key_type, mapped_type> __value_type;
typedef __unordered_map_hasher<key_type, __value_type, hasher> __hasher;
typedef __unordered_map_equal<key_type, __value_type, key_equal> __key_equal;
- typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
+ typedef typename __rebind_counting_alloc_helper<allocator_traits<allocator_type>,
__value_type>::type __allocator_type;
typedef __hash_table<__value_type, __hasher,
@@ -1435,8 +1429,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node()
__node_allocator& __na = __table_.__node_alloc();
__node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
__node_traits::construct(__na, _VSTD::addressof(__h->__value_));
- __h.get_deleter().__first_constructed = true;
- __h.get_deleter().__second_constructed = true;
+ __h.get_deleter().__constructed = true;
return __h;
}
@@ -1449,8 +1442,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0)
__node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
__node_traits::construct(__na, _VSTD::addressof(__h->__value_),
_VSTD::forward<_A0>(__a0));
- __h.get_deleter().__first_constructed = true;
- __h.get_deleter().__second_constructed = true;
+ __h.get_deleter().__constructed = true;
return __h;
}
@@ -1460,10 +1452,9 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(key_ty
{
__node_allocator& __na = __table_.__node_alloc();
__node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
- __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first), _VSTD::move(__k));
- __h.get_deleter().__first_constructed = true;
- __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second));
- __h.get_deleter().__second_constructed = true;
+ __node_traits::construct(__na, _VSTD::addressof(__h->__value_), _VSTD::piecewise_construct,
+ _VSTD::forward_as_tuple(_VSTD::move(__k)), _VSTD::forward_as_tuple());
+ __h.get_deleter().__constructed = true;
return __h;
}
@@ -1481,8 +1472,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0,
__node_traits::construct(__na, _VSTD::addressof(__h->__value_),
_VSTD::forward<_A0>(__a0), _VSTD::forward<_A1>(__a1),
_VSTD::forward<_Args>(__args)...);
- __h.get_deleter().__first_constructed = true;
- __h.get_deleter().__second_constructed = true;
+ __h.get_deleter().__constructed = true;
return __h;
}
@@ -1498,22 +1488,21 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::emplace(_Args&&... __args)
return __r;
}
-#endif // _LIBCPP_HAS_NO_VARIADICS
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(const key_type& __k)
{
__node_allocator& __na = __table_.__node_alloc();
__node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
- __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first), __k);
- __h.get_deleter().__first_constructed = true;
- __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second));
- __h.get_deleter().__second_constructed = true;
- return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03
+ __node_traits::construct(__na, _VSTD::addressof(__h->__value_), _VSTD::piecewise_construct,
+ _VSTD::forward_as_tuple(__k), _VSTD::forward_as_tuple());
+ __h.get_deleter().__constructed = true;
+ return __h;
}
+#endif // _LIBCPP_HAS_NO_VARIADICS
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
template <class _InputIterator>
inline _LIBCPP_INLINE_VISIBILITY
@@ -1618,7 +1607,7 @@ operator!=(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
}
template <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>,
- class _Alloc = allocator<pair<const _Key, _Tp> > >
+ class _Alloc = counting_allocator<pair<const _Key, _Tp>, allocation_group::unordered_multimap > >
class _LIBCPP_TYPE_VIS_ONLY unordered_multimap
{
public:
@@ -1639,7 +1628,7 @@ private:
typedef __hash_value_type<key_type, mapped_type> __value_type;
typedef __unordered_map_hasher<key_type, __value_type, hasher> __hasher;
typedef __unordered_map_equal<key_type, __value_type, key_equal> __key_equal;
- typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
+ typedef typename __rebind_counting_alloc_helper<allocator_traits<allocator_type>,
__value_type>::type __allocator_type;
typedef __hash_table<__value_type, __hasher,
@@ -2130,8 +2119,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node()
__node_allocator& __na = __table_.__node_alloc();
__node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
__node_traits::construct(__na, _VSTD::addressof(__h->__value_));
- __h.get_deleter().__first_constructed = true;
- __h.get_deleter().__second_constructed = true;
+ __h.get_deleter().__constructed = true;
return __h;
}
@@ -2144,8 +2132,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0
__node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
__node_traits::construct(__na, _VSTD::addressof(__h->__value_),
_VSTD::forward<_A0>(__a0));
- __h.get_deleter().__first_constructed = true;
- __h.get_deleter().__second_constructed = true;
+ __h.get_deleter().__constructed = true;
return __h;
}
@@ -2162,8 +2149,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(
__node_traits::construct(__na, _VSTD::addressof(__h->__value_),
_VSTD::forward<_A0>(__a0), _VSTD::forward<_A1>(__a1),
_VSTD::forward<_Args>(__args)...);
- __h.get_deleter().__first_constructed = true;
- __h.get_deleter().__second_constructed = true;
+ __h.get_deleter().__constructed = true;
return __h;
}
« no previous file with comments | « include/string ('k') | include/unordered_set » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698