From 32638859460984f0e3494fcad9627c4830472cf3 Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Mon, 7 Oct 2024 16:09:17 -0700 Subject: [PATCH] Use iter_swap for one element ranges --- libcxx/include/__algorithm/swap_ranges.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libcxx/include/__algorithm/swap_ranges.h b/libcxx/include/__algorithm/swap_ranges.h index e94f02b45c725c..8ddaae94b5af56 100644 --- a/libcxx/include/__algorithm/swap_ranges.h +++ b/libcxx/include/__algorithm/swap_ranges.h @@ -49,10 +49,8 @@ __swap_ranges(_ForwardIterator1 __first1, _Sentinel1 __last1, _ForwardIterator2 is_same_v<_V1Type, _V2Type> && is_trivially_relocatable_v<_V1Type> && is_replaceable_v<_V1Type>) { size_t __distance = distance(__first1, __last1); - if (__distance == 1) { - using std::swap; - swap(*__first1, *__first2); - } + if (__distance == 1) + iter_swap(__first1, __first2); else if (__distance > 0) { size_t __numBytes = __distance * sizeof(_V1Type); byte *__aptr = reinterpret_cast (addressof(*__first1));