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

Unified Diff: include/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/list ('k') | include/memory » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/map
diff --git a/include/map b/include/map
index adfb4cdb5e9ec5045ec1a93d29dd93e852e3db58..f7202f8ebb51e6b4a6d082d372ee648e273382e9 100644
--- a/include/map
+++ b/include/map
@@ -572,22 +572,19 @@ private:
__map_node_destructor& operator=(const __map_node_destructor&);
public:
- bool __first_constructed;
- bool __second_constructed;
+ bool __constructed;
_LIBCPP_INLINE_VISIBILITY
explicit __map_node_destructor(allocator_type& __na) _NOEXCEPT
: __na_(__na),
- __first_constructed(false),
- __second_constructed(false)
+ __constructed(false)
{}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
__map_node_destructor(__tree_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;
}
@@ -596,10 +593,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);
}
@@ -826,7 +821,7 @@ public:
};
template <class _Key, class _Tp, class _Compare = less<_Key>,
- class _Allocator = allocator<pair<const _Key, _Tp> > >
+ class _Allocator = counting_allocator<pair<const _Key, _Tp>, allocation_group::map> >
class _LIBCPP_TYPE_VIS_ONLY map
{
public:
@@ -861,8 +856,8 @@ private:
typedef _VSTD::__value_type<key_type, mapped_type> __value_type;
typedef __map_value_compare<key_type, __value_type, key_compare> __vc;
- typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
- __value_type>::type __allocator_type;
+ typedef typename __rebind_counting_alloc_helper<allocator_traits<allocator_type>,
+ __value_type>::type __allocator_type;
typedef __tree<__value_type, __vc, __allocator_type> __base;
typedef typename __base::__node_traits __node_traits;
typedef allocator_traits<allocator_type> __alloc_traits;
@@ -1462,10 +1457,8 @@ map<_Key, _Tp, _Compare, _Allocator>::__construct_node()
{
__node_allocator& __na = __tree_.__node_alloc();
__node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
- __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first));
- __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_));
+ __h.get_deleter().__constructed = true;
return __h;
}
@@ -1477,8 +1470,7 @@ map<_Key, _Tp, _Compare, _Allocator>::__construct_node(_A0&& __a0)
__node_allocator& __na = __tree_.__node_alloc();
__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;
}
@@ -1488,10 +1480,9 @@ map<_Key, _Tp, _Compare, _Allocator>::__construct_node_with_key(key_type&& __k)
{
__node_allocator& __na = __tree_.__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;
}
@@ -1507,28 +1498,26 @@ map<_Key, _Tp, _Compare, _Allocator>::__construct_node(_A0&& __a0, _A1&& __a1, _
__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;
}
-#endif // _LIBCPP_HAS_NO_VARIADICS
-
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
template <class _Key, class _Tp, class _Compare, class _Allocator>
typename map<_Key, _Tp, _Compare, _Allocator>::__node_holder
map<_Key, _Tp, _Compare, _Allocator>::__construct_node_with_key(const key_type& __k)
{
__node_allocator& __na = __tree_.__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;
+ __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 _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03
}
+#endif // _LIBCPP_HAS_NO_VARIADICS
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
template <class _Key, class _Tp, class _Compare, class _Allocator>
_Tp&
map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k)
@@ -1685,7 +1674,7 @@ swap(map<_Key, _Tp, _Compare, _Allocator>& __x,
}
template <class _Key, class _Tp, class _Compare = less<_Key>,
- class _Allocator = allocator<pair<const _Key, _Tp> > >
+ class _Allocator = counting_allocator<pair<const _Key, _Tp>, allocation_group::multimap > >
class _LIBCPP_TYPE_VIS_ONLY multimap
{
public:
@@ -1721,7 +1710,7 @@ private:
typedef _VSTD::__value_type<key_type, mapped_type> __value_type;
typedef __map_value_compare<key_type, __value_type, key_compare> __vc;
- 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 __tree<__value_type, __vc, __allocator_type> __base;
typedef typename __base::__node_traits __node_traits;
@@ -2100,10 +2089,8 @@ multimap<_Key, _Tp, _Compare, _Allocator>::__construct_node()
{
__node_allocator& __na = __tree_.__node_alloc();
__node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
- __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first));
- __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_));
+ __h.get_deleter().__constructed = true;
return __h;
}
@@ -2115,8 +2102,7 @@ multimap<_Key, _Tp, _Compare, _Allocator>::__construct_node(_A0&& __a0)
__node_allocator& __na = __tree_.__node_alloc();
__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;
}
@@ -2132,8 +2118,7 @@ multimap<_Key, _Tp, _Compare, _Allocator>::__construct_node(_A0&& __a0, _A1&& __
__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/list ('k') | include/memory » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698