[libcxx-commits] [libcxx] 1ce516d - [libc++] Minor fixups in the new introsort code.
Arthur O'Dwyer via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Nov 18 08:02:01 PST 2021
Author: Arthur O'Dwyer
Date: 2021-11-18T11:01:41-05:00
New Revision: 1ce516d43f105f4ffc36da7627ee51c0c507d1e9
URL: https://github.com/llvm/llvm-project/commit/1ce516d43f105f4ffc36da7627ee51c0c507d1e9
DIFF: https://github.com/llvm/llvm-project/commit/1ce516d43f105f4ffc36da7627ee51c0c507d1e9.diff
LOG: [libc++] Minor fixups in the new introsort code.
Differential Revision: https://reviews.llvm.org/D114133
Added:
Modified:
libcxx/include/__algorithm/sort.h
Removed:
################################################################################
diff --git a/libcxx/include/__algorithm/sort.h b/libcxx/include/__algorithm/sort.h
index 24d0a4935b4ca..c2f6a62b61667 100644
--- a/libcxx/include/__algorithm/sort.h
+++ b/libcxx/include/__algorithm/sort.h
@@ -131,7 +131,7 @@ __selection_sort(_BidirectionalIterator __first, _BidirectionalIterator __last,
_BidirectionalIterator __lm1 = __last;
for (--__lm1; __first != __lm1; ++__first)
{
- _BidirectionalIterator __i = _VSTD::min_element<_BidirectionalIterator, _Compare&>(__first, __last, __comp);
+ _BidirectionalIterator __i = _VSTD::min_element(__first, __last, __comp);
if (__i != __first)
swap(*__first, *__i);
}
@@ -268,13 +268,12 @@ __insertion_sort_move(_BidirectionalIterator __first1, _BidirectionalIterator __
template <class _Compare, class _RandomAccessIterator>
void
__introsort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
- typename _VSTD::iterator_traits<_RandomAccessIterator>::
diff erence_type __depth)
+ typename iterator_traits<_RandomAccessIterator>::
diff erence_type __depth)
{
typedef typename iterator_traits<_RandomAccessIterator>::
diff erence_type
diff erence_type;
typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
const
diff erence_type __limit = is_trivially_copy_constructible<value_type>::value &&
is_trivially_copy_assignable<value_type>::value ? 30 : 6;
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
while (true)
{
__restart:
@@ -307,7 +306,7 @@ __introsort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compar
if (__depth == 0)
{
// Fallback to heap sort as Introsort suggests.
- _VSTD::__partial_sort<_Comp_ref>(__first, __last, __last, _Comp_ref(__comp));
+ _VSTD::__partial_sort<_Compare>(__first, __last, __last, __comp);
return;
}
--__depth;
@@ -478,7 +477,7 @@ template <class _Compare, class _RandomAccessIterator>
void __sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
typedef typename iterator_traits<_RandomAccessIterator>::
diff erence_type
diff erence_type;
diff erence_type __depth_limit = 2 * __log2i(__last - __first);
- __introsort(__first, __last, __comp, __depth_limit);
+ _VSTD::__introsort<_Compare>(__first, __last, __comp, __depth_limit);
}
template <class _Compare, class _Tp>
More information about the libcxx-commits
mailing list