From e62307421053f527e2837e7a4d1d3c246b39303f Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Tue, 2 Jun 2015 13:04:18 +0000 Subject: [PATCH] In the case where we are copying/moving zero elements, do less work llvm-svn: 238828 --- libcxx/include/memory | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libcxx/include/memory b/libcxx/include/memory index 6f3fdd5..4e3a6f8 100644 --- a/libcxx/include/memory +++ b/libcxx/include/memory @@ -1522,8 +1522,10 @@ struct _LIBCPP_TYPE_VIS_ONLY allocator_traits { ptrdiff_t _Np = __end1 - __begin1; if (_Np > 0) + { _VSTD::memcpy(__begin2, __begin1, _Np * sizeof(_Tp)); - __begin2 += _Np; + __begin2 += _Np; + } } template @@ -1551,8 +1553,10 @@ struct _LIBCPP_TYPE_VIS_ONLY allocator_traits typedef typename remove_const<_Tp>::type _Vp; ptrdiff_t _Np = __end1 - __begin1; if (_Np > 0) + { _VSTD::memcpy(const_cast<_Vp*>(__begin2), __begin1, _Np * sizeof(_Tp)); - __begin2 += _Np; + __begin2 += _Np; + } } template -- 2.7.4