dit pointed out on IRC that '__i = _VSTD::next(__i)' was a very long-winded way of writing '++__i'. Since I hate being thought of as long-winded (this checkin comment notwithstanding), I fixed it. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@214834 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c09c2865b9
commit
ea8ed833fe
78
include/list
78
include/list
@ -214,10 +214,13 @@ struct __list_node_base
|
|||||||
pointer __next_;
|
pointer __next_;
|
||||||
|
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
__list_node_base()
|
__list_node_base() : __prev_(__self()), __next_(__self()) {}
|
||||||
: __prev_(static_cast<pointer>(pointer_traits<__base_pointer>::pointer_to(*this))),
|
|
||||||
__next_(static_cast<pointer>(pointer_traits<__base_pointer>::pointer_to(*this)))
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
{}
|
pointer __self()
|
||||||
|
{
|
||||||
|
return static_cast<pointer>(pointer_traits<__base_pointer>::pointer_to(*this));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class _Tp, class _VoidPtr>
|
template <class _Tp, class _VoidPtr>
|
||||||
@ -753,20 +756,14 @@ __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)
|
|||||||
swap(__sz(), __c.__sz());
|
swap(__sz(), __c.__sz());
|
||||||
swap(__end_, __c.__end_);
|
swap(__end_, __c.__end_);
|
||||||
if (__sz() == 0)
|
if (__sz() == 0)
|
||||||
__end_.__next_ = __end_.__prev_ = static_cast<__node_pointer>(
|
__end_.__next_ = __end_.__prev_ = __end_.__self();
|
||||||
pointer_traits<__node_base_pointer>::pointer_to(__end_));
|
|
||||||
else
|
else
|
||||||
__end_.__prev_->__next_ = __end_.__next_->__prev_
|
__end_.__prev_->__next_ = __end_.__next_->__prev_ = __end_.__self();
|
||||||
= static_cast<__node_pointer>(
|
|
||||||
pointer_traits<__node_base_pointer>::pointer_to(__end_));
|
|
||||||
if (__c.__sz() == 0)
|
if (__c.__sz() == 0)
|
||||||
__c.__end_.__next_ = __c.__end_.__prev_
|
__c.__end_.__next_ = __c.__end_.__prev_ = __c.__end_.__self();
|
||||||
= static_cast<__node_pointer>(
|
|
||||||
pointer_traits<__node_base_pointer>::pointer_to(__c.__end_));
|
|
||||||
else
|
else
|
||||||
__c.__end_.__prev_->__next_ = __c.__end_.__next_->__prev_
|
__c.__end_.__prev_->__next_ = __c.__end_.__next_->__prev_ = __c.__end_.__self();
|
||||||
= static_cast<__node_pointer>(
|
|
||||||
pointer_traits<__node_base_pointer>::pointer_to(__c.__end_));
|
|
||||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||||
__libcpp_db* __db = __get_db();
|
__libcpp_db* __db = __get_db();
|
||||||
__c_node* __cn1 = __db->__find_c_and_lock(this);
|
__c_node* __cn1 = __db->__find_c_and_lock(this);
|
||||||
@ -1059,7 +1056,9 @@ public:
|
|||||||
#endif // _LIBCPP_DEBUG_LEVEL >= 2
|
#endif // _LIBCPP_DEBUG_LEVEL >= 2
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void __link_nodes(__node_pointer __p, __node_pointer __f, __node_pointer __l);
|
static void __link_nodes (__node_pointer __p, __node_pointer __f, __node_pointer __l);
|
||||||
|
void __link_nodes_at_front(__node_pointer __f, __node_pointer __l);
|
||||||
|
void __link_nodes_at_back (__node_pointer __f, __node_pointer __l);
|
||||||
iterator __iterator(size_type __n);
|
iterator __iterator(size_type __n);
|
||||||
template <class _Comp>
|
template <class _Comp>
|
||||||
static iterator __sort(iterator __f1, iterator __e2, size_type __n, _Comp& __comp);
|
static iterator __sort(iterator __f1, iterator __e2, size_type __n, _Comp& __comp);
|
||||||
@ -1081,6 +1080,31 @@ list<_Tp, _Alloc>::__link_nodes(__node_pointer __p, __node_pointer __f, __node_p
|
|||||||
__l->__next_ = __p;
|
__l->__next_ = __p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Link in nodes [__f, __l] at the front of the list
|
||||||
|
template <class _Tp, class _Alloc>
|
||||||
|
inline _LIBCPP_INLINE_VISIBILITY
|
||||||
|
void
|
||||||
|
list<_Tp, _Alloc>::__link_nodes_at_front(__node_pointer __f, __node_pointer __l)
|
||||||
|
{
|
||||||
|
__f->__prev_ = base::__end_.__self();
|
||||||
|
__l->__next_ = base::__end_.__next_;
|
||||||
|
__l->__next_->__prev_ = __l;
|
||||||
|
base::__end_.__next_ = __f;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Link in nodes [__f, __l] at the front of the list
|
||||||
|
template <class _Tp, class _Alloc>
|
||||||
|
inline _LIBCPP_INLINE_VISIBILITY
|
||||||
|
void
|
||||||
|
list<_Tp, _Alloc>::__link_nodes_at_back(__node_pointer __f, __node_pointer __l)
|
||||||
|
{
|
||||||
|
__l->__next_ = base::__end_.__self();
|
||||||
|
__f->__prev_ = base::__end_.__prev_;
|
||||||
|
__f->__prev_->__next_ = __f;
|
||||||
|
base::__end_.__prev_ = __l;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class _Tp, class _Alloc>
|
template <class _Tp, class _Alloc>
|
||||||
inline _LIBCPP_INLINE_VISIBILITY
|
inline _LIBCPP_INLINE_VISIBILITY
|
||||||
typename list<_Tp, _Alloc>::iterator
|
typename list<_Tp, _Alloc>::iterator
|
||||||
@ -1502,7 +1526,7 @@ list<_Tp, _Alloc>::push_front(const value_type& __x)
|
|||||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||||
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
||||||
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
|
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
|
||||||
__link_nodes(base::__end_.__next_, __hold.get(), __hold.get());
|
__link_nodes_at_front(__hold.get(), __hold.get());
|
||||||
++base::__sz();
|
++base::__sz();
|
||||||
__hold.release();
|
__hold.release();
|
||||||
}
|
}
|
||||||
@ -1515,8 +1539,7 @@ list<_Tp, _Alloc>::push_back(const value_type& __x)
|
|||||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||||
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
||||||
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
|
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
|
||||||
__link_nodes(static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::
|
__link_nodes_at_back(__hold.get(), __hold.get());
|
||||||
pointer_to(base::__end_)), __hold.get(), __hold.get());
|
|
||||||
++base::__sz();
|
++base::__sz();
|
||||||
__hold.release();
|
__hold.release();
|
||||||
}
|
}
|
||||||
@ -1531,7 +1554,7 @@ list<_Tp, _Alloc>::push_front(value_type&& __x)
|
|||||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||||
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
||||||
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::move(__x));
|
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::move(__x));
|
||||||
__link_nodes(base::__end_.__next_, __hold.get(), __hold.get());
|
__link_nodes_at_front(__hold.get(), __hold.get());
|
||||||
++base::__sz();
|
++base::__sz();
|
||||||
__hold.release();
|
__hold.release();
|
||||||
}
|
}
|
||||||
@ -1544,8 +1567,7 @@ list<_Tp, _Alloc>::push_back(value_type&& __x)
|
|||||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||||
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
||||||
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::move(__x));
|
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::move(__x));
|
||||||
__link_nodes(static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::
|
__link_nodes_at_back(__hold.get(), __hold.get());
|
||||||
pointer_to(base::__end_)), __hold.get(), __hold.get());
|
|
||||||
++base::__sz();
|
++base::__sz();
|
||||||
__hold.release();
|
__hold.release();
|
||||||
}
|
}
|
||||||
@ -1561,7 +1583,7 @@ list<_Tp, _Alloc>::emplace_front(_Args&&... __args)
|
|||||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||||
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
||||||
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::forward<_Args>(__args)...);
|
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::forward<_Args>(__args)...);
|
||||||
__link_nodes(base::__end_.__next_, __hold.get(), __hold.get());
|
__link_nodes_at_front(__hold.get(), __hold.get());
|
||||||
++base::__sz();
|
++base::__sz();
|
||||||
__hold.release();
|
__hold.release();
|
||||||
}
|
}
|
||||||
@ -1575,8 +1597,7 @@ list<_Tp, _Alloc>::emplace_back(_Args&&... __args)
|
|||||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||||
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
||||||
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::forward<_Args>(__args)...);
|
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::forward<_Args>(__args)...);
|
||||||
__link_nodes(static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::
|
__link_nodes_at_back(__hold.get(), __hold.get());
|
||||||
pointer_to(base::__end_)), __hold.get(), __hold.get());
|
|
||||||
++base::__sz();
|
++base::__sz();
|
||||||
__hold.release();
|
__hold.release();
|
||||||
}
|
}
|
||||||
@ -1826,8 +1847,7 @@ list<_Tp, _Alloc>::resize(size_type __n)
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||||
__link_nodes(static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::
|
__link_nodes_at_back(__r.__ptr_, __e.__ptr_);
|
||||||
pointer_to(base::__end_)), __r.__ptr_, __e.__ptr_);
|
|
||||||
base::__sz() += __ds;
|
base::__sz() += __ds;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2047,7 +2067,7 @@ list<_Tp, _Alloc>::remove(const value_type& __x)
|
|||||||
;
|
;
|
||||||
__i = erase(__i, __j);
|
__i = erase(__i, __j);
|
||||||
if (__i != __e)
|
if (__i != __e)
|
||||||
__i = _VSTD::next(__i);
|
++__i;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
++__i;
|
++__i;
|
||||||
@ -2068,7 +2088,7 @@ list<_Tp, _Alloc>::remove_if(_Pred __pred)
|
|||||||
;
|
;
|
||||||
__i = erase(__i, __j);
|
__i = erase(__i, __j);
|
||||||
if (__i != __e)
|
if (__i != __e)
|
||||||
__i = _VSTD::next(__i);
|
++__i;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
++__i;
|
++__i;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user