From ae2dfb178dd0a5062ed7cafe134f217dd1fc551b Mon Sep 17 00:00:00 2001 From: Michael Schellenberger Costa Date: Mon, 12 Oct 2020 20:56:18 +0200 Subject: [PATCH] Use _Memmove_meow as we use it ouside of copy algorithms --- stl/inc/algorithm | 2 +- stl/inc/memory | 18 +++++++++--------- stl/inc/vector | 4 ++-- stl/inc/xmemory | 16 ++++++++-------- stl/inc/xutility | 36 ++++++++++++++++++------------------ 5 files changed, 38 insertions(+), 38 deletions(-) diff --git a/stl/inc/algorithm b/stl/inc/algorithm index 779ab60956..a027ca8371 100644 --- a/stl/inc/algorithm +++ b/stl/inc/algorithm @@ -1852,7 +1852,7 @@ namespace ranges { _NODISCARD constexpr _It2 _Move_backward_common(const _It1 _First, _It1 _Last, _It2 _Result) { if constexpr (_Memmove_in_move_is_safe<_It1, _It2>) { if (!_STD is_constant_evaluated()) { - return _Copy_backward_memmove(_First, _Last, _Result); + return _Memmove_backward(_First, _Last, _Result); } } diff --git a/stl/inc/memory b/stl/inc/memory index 7670f03485..bc16c897de 100644 --- a/stl/inc/memory +++ b/stl/inc/memory @@ -108,7 +108,7 @@ namespace ranges { _STL_INTERNAL_STATIC_ASSERT(constructible_from, iter_reference_t<_It>>); if constexpr (is_same_v<_Se, _It> && _Memmove_in_uninitialized_copy_is_safe<_It, _Out>) { - return _Copy_memcpy_common(_IFirst, _ILast, _OFirst, _OLast); + return _Memmove_forward_common(_IFirst, _ILast, _OFirst, _OLast); } else { _Uninitialized_backout _Backout{_STD move(_OFirst)}; @@ -138,7 +138,7 @@ _NoThrowFwdIt uninitialized_copy_n(const _InIt _First, const _Diff _Count_raw, _ auto _UFirst = _Get_unwrapped_n(_First, _Count); auto _UDest = _Get_unwrapped_n(_Dest, _Count); if constexpr (_Memmove_in_uninitialized_copy_is_safe) { - _UDest = _Copy_memmove(_UFirst, _UFirst + _Count, _UDest); + _UDest = _Memmove_forward(_UFirst, _UFirst + _Count, _UDest); } else { _Uninitialized_backout _Backout{_UDest}; @@ -168,7 +168,7 @@ _NoThrowFwdIt _Uninitialized_copy_n_unchecked2(_InIt _First, _Diff _Count, const template _NoThrowFwdIt _Uninitialized_copy_n_unchecked2(const _InIt _First, const _Diff _Count, const _NoThrowFwdIt _Dest, true_type) { // copy [_First, _First + _Count) to [_Dest, ...), memmove optimization - return _Copy_memmove(_First, _First + _Count, _Dest); + return _Memmove_forward(_First, _First + _Count, _Dest); } template @@ -214,7 +214,7 @@ namespace ranges { auto _OFirst = _Get_unwrapped(_STD move(_First2)); const auto _OLast = _Get_unwrapped(_STD move(_Last2)); if constexpr (_Memmove_in_uninitialized_copy_is_safe<_It, _Out>) { - _OFirst = _Copy_memcpy_common(_IFirst, _IFirst + _Count, _OFirst, _OLast); + _OFirst = _Memmove_forward_common(_IFirst, _IFirst + _Count, _OFirst, _OLast); } else { _Uninitialized_backout _Backout{_STD move(_OFirst)}; @@ -301,7 +301,7 @@ namespace ranges { _STL_INTERNAL_STATIC_ASSERT(constructible_from, iter_rvalue_reference_t<_It>>); if constexpr (is_same_v<_Se, _It> && _Memmove_in_uninitialized_move_is_safe<_It, _Out>) { - return _Copy_memcpy_common(_IFirst, _ILast, _OFirst, _OLast); + return _Memmove_forward_common(_IFirst, _ILast, _OFirst, _OLast); } else { _Uninitialized_backout _Backout{_STD move(_OFirst)}; @@ -330,7 +330,7 @@ pair<_InIt, _NoThrowFwdIt> uninitialized_move_n(_InIt _First, const _Diff _Count auto _UFirst = _Get_unwrapped_n(_First, _Count); auto _UDest = _Get_unwrapped_n(_Dest, _Count); if constexpr (_Memmove_in_uninitialized_move_is_safe) { - _UDest = _Copy_memmove(_UFirst, _UFirst + _Count, _UDest); + _UDest = _Memmove_forward(_UFirst, _UFirst + _Count, _UDest); _UFirst += _Count; } else { _Uninitialized_backout _Backout{_UDest}; @@ -375,7 +375,7 @@ namespace ranges { auto _OFirst = _Get_unwrapped(_STD move(_First2)); const auto _OLast = _Get_unwrapped(_STD move(_Last2)); if constexpr (_Memmove_in_uninitialized_move_is_safe<_It, _Out>) { - _OFirst = _Copy_memcpy_common(_IFirst, _IFirst + _Count, _OFirst, _OLast); + _OFirst = _Memmove_forward_common(_IFirst, _IFirst + _Count, _OFirst, _OLast); } else { _Uninitialized_backout _Backout{_STD move(_OFirst)}; @@ -2316,7 +2316,7 @@ struct _Reverse_destroy_multidimensional_n_guard { template void _Uninitialized_copy_multidimensional(const _Ty (&_In)[_Size], _Ty (&_Out)[_Size]) { if constexpr (is_trivial_v<_Ty>) { - _Copy_memmove(_In, _In + _Size, _Out); + _Memmove_forward(_In, _In + _Size, _Out); } else if constexpr (is_array_v<_Ty>) { _Reverse_destroy_multidimensional_n_guard<_Ty> _Guard{_Out, 0}; for (size_t& _Idx = _Guard._Index; _Idx < _Size; ++_Idx) { @@ -2639,7 +2639,7 @@ template void _Uninitialized_copy_multidimensional_al(const _Ty (&_In)[_Size], _Ty (&_Out)[_Size], _Alloc& _Al) { using _Item = remove_all_extents_t<_Ty>; if constexpr (conjunction_v, _Uses_default_construct<_Alloc, _Item*, const _Item&>>) { - _Copy_memmove(_In, _In + _Size, _Out); + _Memmove_forward(_In, _In + _Size, _Out); } else if constexpr (is_array_v<_Ty>) { _Reverse_destroy_multidimensional_n_al_guard<_Ty, _Alloc> _Guard{_Out, 0, _Al}; for (size_t& _Idx = _Guard._Index; _Idx < _Size; ++_Idx) { diff --git a/stl/inc/vector b/stl/inc/vector index 5a20178c26..348c80a216 100644 --- a/stl/inc/vector +++ b/stl/inc/vector @@ -642,7 +642,7 @@ private: _Clear_and_reserve_geometric(_Newsize); } - _Mylast = _Refancy(_Copy_memmove(_Unfancy(_First), _Unfancy(_Last), _Unfancy(_Myfirst))); + _Mylast = _Refancy(_Memmove_forward(_Unfancy(_First), _Unfancy(_Last), _Unfancy(_Myfirst))); } else #endif // _HAS_IF_CONSTEXPR { @@ -1116,7 +1116,7 @@ private: _Clear_and_reserve_geometric(_Newsize); } - _Mylast = _Refancy(_Copy_memmove(_First, _Last, _Unfancy(_Myfirst))); + _Mylast = _Refancy(_Memmove_forward(_First, _Last, _Unfancy(_Myfirst))); } else #endif // _HAS_IF_CONSTEXPR { diff --git a/stl/inc/xmemory b/stl/inc/xmemory index d10cb91aab..19bcb23411 100644 --- a/stl/inc/xmemory +++ b/stl/inc/xmemory @@ -1481,7 +1481,7 @@ template _NoThrowFwdIt _Uninitialized_move_unchecked(_InIt _First, const _InIt _Last, _NoThrowFwdIt _Dest) { // move [_First, _Last) to raw [_Dest, ...) if constexpr (_Memmove_in_uninitialized_move_is_safe<_InIt, _NoThrowFwdIt>) { - return _Copy_memmove(_First, _Last, _Dest); + return _Memmove_forward(_First, _Last, _Dest); } else { _Uninitialized_backout<_NoThrowFwdIt> _Backout{_Dest}; for (; _First != _Last; ++_First) { @@ -1507,7 +1507,7 @@ template _NoThrowFwdIt _Uninitialized_move_unchecked1( const _InIt _First, const _InIt _Last, const _NoThrowFwdIt _Dest, true_type) { // move [_First, _Last) to raw [_Dest, ...), memmove optimization - return _Copy_memmove(_First, _Last, _Dest); + return _Memmove_forward(_First, _Last, _Dest); } template @@ -1564,7 +1564,7 @@ _Alloc_ptr_t<_Alloc> _Uninitialized_copy( if constexpr (conjunction_v>, _Uses_default_construct<_Alloc, _Ptrval, decltype(*_UFirst)>>) { - _Copy_memmove(_UFirst, _ULast, _Unfancy(_Dest)); + _Memmove_forward(_UFirst, _ULast, _Unfancy(_Dest)); _Dest += _ULast - _UFirst; } else { _Uninitialized_backout_al<_Alloc> _Backout{_Dest, _Al}; @@ -1594,7 +1594,7 @@ template _Alloc_ptr_t<_Alloc> _Uninitialized_copy_al_unchecked( const _InIt _First, const _InIt _Last, const _Alloc_ptr_t<_Alloc> _Dest, _Alloc&, true_type) { // copy [_First, _Last) to raw _Dest, using default _Alloc construct, memmove optimization - return _Copy_memmove(_First, _Last, _Unfancy(_Dest)); + return _Memmove_forward(_First, _Last, _Unfancy(_Dest)); } template @@ -1625,7 +1625,7 @@ _NoThrowFwdIt uninitialized_copy(const _InIt _First, const _InIt _Last, _NoThrow const auto _ULast = _Get_unwrapped(_Last); auto _UDest = _Get_unwrapped_n(_Dest, _Idl_distance<_InIt>(_UFirst, _ULast)); if constexpr (_Memmove_in_uninitialized_copy_is_safe) { - _UDest = _Copy_memmove(_UFirst, _ULast, _UDest); + _UDest = _Memmove_forward(_UFirst, _ULast, _UDest); } else { _Uninitialized_backout _Backout{_UDest}; for (; _UFirst != _ULast; ++_UFirst) { @@ -1654,7 +1654,7 @@ template _NoThrowFwdIt _Uninitialized_copy_unchecked( const _InIt _First, const _InIt _Last, const _NoThrowFwdIt _Dest, true_type) { // copy [_First, _Last) to raw [_Dest, ...), memmove optimization - return _Copy_memmove(_First, _Last, _Dest); + return _Memmove_forward(_First, _Last, _Dest); } template @@ -1683,7 +1683,7 @@ _Alloc_ptr_t<_Alloc> _Uninitialized_move( const auto _ULast = _Get_unwrapped(_Last); if constexpr (conjunction_v>, _Uses_default_construct<_Alloc, _Ptrval, decltype(_STD move(*_UFirst))>>) { - _Copy_memmove(_UFirst, _ULast, _Unfancy(_Dest)); + _Memmove_forward(_UFirst, _ULast, _Unfancy(_Dest)); return _Dest + (_ULast - _UFirst); } else { _Uninitialized_backout_al<_Alloc> _Backout{_Dest, _Al}; @@ -1711,7 +1711,7 @@ template _Alloc_ptr_t<_Alloc> _Uninitialized_move_al_unchecked( const _InIt _First, const _InIt _Last, _Alloc_ptr_t<_Alloc> _Dest, _Alloc&, true_type) { // move [_First, _Last) to raw _Dest, using default _Alloc construct, memmove optimization - _Copy_memmove(_First, _Last, _Unfancy(_Dest)); + _Memmove_forward(_First, _Last, _Unfancy(_Dest)); return _Dest + (_Last - _First); } diff --git a/stl/inc/xutility b/stl/inc/xutility index 4d5903e200..0ac84fcee8 100644 --- a/stl/inc/xutility +++ b/stl/inc/xutility @@ -4408,7 +4408,7 @@ _INLINE_VAR constexpr bool _Memmove_in_uninitialized_move_is_safe = _Can_memop, _IterDest, _Memop_cat::_Move_uninitialized>; template -_OutIt _Copy_memmove(_InIt _First, _InIt _Last, _OutIt _Dest) { +_OutIt _Memmove_forward(_InIt _First, _InIt _Last, _OutIt _Dest) { const char* const _First_ch = const_cast(reinterpret_cast(_First)); const char* const _Last_ch = const_cast(reinterpret_cast(_Last)); char* const _Dest_ch = const_cast(reinterpret_cast(_Dest)); @@ -4418,18 +4418,18 @@ _OutIt _Copy_memmove(_InIt _First, _InIt _Last, _OutIt _Dest) { } template -_OutIt _Copy_memmove(move_iterator<_InIt> _First, move_iterator<_InIt> _Last, _OutIt _Dest) { - return _Copy_memmove(_First.base(), _Last.base(), _Dest); +_OutIt _Memmove_forward(move_iterator<_InIt> _First, move_iterator<_InIt> _Last, _OutIt _Dest) { + return _Memmove_forward(_First.base(), _Last.base(), _Dest); } template -_OutIt _Copy_memcpy_common(_InIt _IFirst, _InIt _ILast, _OutIt _OFirst, _OutIt _OLast) noexcept { +_OutIt _Memmove_forward_common(_InIt _IFirst, _InIt _ILast, _OutIt _OFirst, _OutIt _OLast) noexcept { const auto _IFirst_ch = const_cast(reinterpret_cast(_IFirst)); const auto _ILast_ch = const_cast(reinterpret_cast(_ILast)); const auto _OFirst_ch = const_cast(reinterpret_cast(_OFirst)); const auto _OLast_ch = const_cast(reinterpret_cast(_OLast)); const auto _Count = static_cast((_STD min)(_ILast_ch - _IFirst_ch, _OLast_ch - _OFirst_ch)); - _CSTD memcpy(_OFirst_ch, _IFirst_ch, _Count); + _CSTD memmove(_OFirst_ch, _IFirst_ch, _Count); return reinterpret_cast<_OutIt>(_OFirst_ch + _Count); } @@ -4447,7 +4447,7 @@ _CONSTEXPR20 _OutIt _Copy_unchecked(_InIt _First, _InIt _Last, _OutIt _Dest) { if (!_STD is_constant_evaluated()) #endif // __cpp_lib_is_constant_evaluated { - return _Copy_memmove(_First, _Last, _Dest); + return _Memmove_forward(_First, _Last, _Dest); } } @@ -4471,7 +4471,7 @@ _OutIt _Copy_unchecked1(_InIt _First, _InIt _Last, _OutIt _Dest, false_type) { template _OutIt _Copy_unchecked1(_InIt _First, _InIt _Last, _OutIt _Dest, true_type) { // copy [_First, _Last) to [_Dest, ...), pointers to trivially copyable - return _Copy_memmove(_First, _Last, _Dest); + return _Memmove_forward(_First, _Last, _Dest); } template @@ -4517,7 +4517,7 @@ _CONSTEXPR20 _OutIt copy_n(_InIt _First, _Diff _Count_raw, _OutIt _Dest) { if (!_STD is_constant_evaluated()) #endif // __cpp_lib_is_constant_evaluated { - _UDest = _Copy_memmove(_UFirst, _UFirst + _Count, _UDest); + _UDest = _Memmove_forward(_UFirst, _UFirst + _Count, _UDest); _Seek_wrapped(_Dest, _UDest); return _Dest; } @@ -4563,7 +4563,7 @@ template _OutIt _Copy_n_unchecked4(_InIt _First, _Diff _Count, _OutIt _Dest, true_type) { // copy [_First, _First + _Count) to [_Dest, ...), memmove optimization // pre: 0 < _Count - return _Copy_memmove(_First, _First + _Count, _Dest); + return _Memmove_forward(_First, _First + _Count, _Dest); } template @@ -4593,7 +4593,7 @@ _FwdIt2 copy_n(_ExPo&&, _FwdIt1 _First, _Diff _Count_raw, _FwdIt2 _Dest) noexcep // FUNCTION TEMPLATE copy_backward template -_BidIt2 _Copy_backward_memmove(_BidIt1 _First, _BidIt1 _Last, _BidIt2 _Dest) { +_BidIt2 _Memmove_backward(_BidIt1 _First, _BidIt1 _Last, _BidIt2 _Dest) { // implement copy_backward-like function as memmove const char* const _First_ch = const_cast(reinterpret_cast(_First)); const char* const _Last_ch = const_cast(reinterpret_cast(_Last)); @@ -4603,8 +4603,8 @@ _BidIt2 _Copy_backward_memmove(_BidIt1 _First, _BidIt1 _Last, _BidIt2 _Dest) { } template -_BidIt2 _Copy_backward_memmove(move_iterator<_BidIt1> _First, move_iterator<_BidIt1> _Last, _BidIt2 _Dest) { - return _Copy_backward_memmove(_First.base(), _Last.base(), _Dest); +_BidIt2 _Memmove_backward(move_iterator<_BidIt1> _First, move_iterator<_BidIt1> _Last, _BidIt2 _Dest) { + return _Memmove_backward(_First.base(), _Last.base(), _Dest); } #if _HAS_IF_CONSTEXPR @@ -4616,7 +4616,7 @@ _NODISCARD _CONSTEXPR20 _BidIt2 _Copy_backward_unchecked(_BidIt1 _First, _BidIt1 if (!_STD is_constant_evaluated()) #endif // __cpp_lib_is_constant_evaluated { - return _Copy_backward_memmove(_First, _Last, _Dest); + return _Memmove_backward(_First, _Last, _Dest); } } @@ -4651,7 +4651,7 @@ _BidIt2 _Copy_backward_unchecked(_BidIt1 _First, _BidIt1 _Last, _BidIt2 _Dest, f template _BidIt2 _Copy_backward_unchecked(_BidIt1 _First, _BidIt1 _Last, _BidIt2 _Dest, true_type) { // copy [_First, _Last) backwards to [..., _Dest), memmove optimization - return _Copy_backward_memmove(_First, _Last, _Dest); + return _Memmove_backward(_First, _Last, _Dest); } template @@ -4686,7 +4686,7 @@ _CONSTEXPR20 _OutIt _Move_unchecked(_InIt _First, _InIt _Last, _OutIt _Dest) { if (!_STD is_constant_evaluated()) #endif // __cpp_lib_is_constant_evaluated { - return _Copy_memmove(_First, _Last, _Dest); + return _Memmove_forward(_First, _Last, _Dest); } } @@ -4710,7 +4710,7 @@ _OutIt _Move_unchecked1(_InIt _First, _InIt _Last, _OutIt _Dest, false_type) { template _OutIt _Move_unchecked1(_InIt _First, _InIt _Last, _OutIt _Dest, true_type) { // move [_First, _Last) to [_Dest, ...), memmove optimization - return _Copy_memmove(_First, _Last, _Dest); + return _Memmove_forward(_First, _Last, _Dest); } template @@ -4754,7 +4754,7 @@ _CONSTEXPR20 _BidIt2 _Move_backward_unchecked(_BidIt1 _First, _BidIt1 _Last, _Bi if (!_STD is_constant_evaluated()) #endif // __cpp_lib_is_constant_evaluated { - return _Copy_backward_memmove(_First, _Last, _Dest); + return _Memmove_backward(_First, _Last, _Dest); } } @@ -4778,7 +4778,7 @@ _BidIt2 _Move_backward_unchecked1(_BidIt1 _First, _BidIt1 _Last, _BidIt2 _Dest, template _BidIt2 _Move_backward_unchecked1(_BidIt1 _First, _BidIt1 _Last, _BidIt2 _Dest, true_type) { // move [_First, _Last) backwards to [..., _Dest), memmove optimization - return _Copy_backward_memmove(_First, _Last, _Dest); + return _Memmove_backward(_First, _Last, _Dest); } template