[libcxx-commits] [libcxx] 811b5f5 - [libc++][NFC] Simplify __sort{4, 5}
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Feb 21 10:42:28 PST 2023
Author: Nikolas Klauser
Date: 2023-02-21T19:42:23+01:00
New Revision: 811b5f52adcbbff5609d14d70a165a2dde654672
URL: https://github.com/llvm/llvm-project/commit/811b5f52adcbbff5609d14d70a165a2dde654672
DIFF: https://github.com/llvm/llvm-project/commit/811b5f52adcbbff5609d14d70a165a2dde654672.diff
LOG: [libc++][NFC] Simplify __sort{4,5}
Don't return the number of swaps; it's not used anywhere.
Reviewed By: Mordante, #libc, avogelsgesang
Spies: libcxx-commits
Differential Revision: https://reviews.llvm.org/D144478
Added:
Modified:
libcxx/include/__algorithm/sort.h
Removed:
################################################################################
diff --git a/libcxx/include/__algorithm/sort.h b/libcxx/include/__algorithm/sort.h
index 73aada120819..c893270eeaa8 100644
--- a/libcxx/include/__algorithm/sort.h
+++ b/libcxx/include/__algorithm/sort.h
@@ -85,50 +85,41 @@ _LIBCPP_CONSTEXPR_SINCE_CXX14 unsigned __sort3(_ForwardIterator __x, _ForwardIte
template <class _AlgPolicy, class _Compare, class _ForwardIterator>
_LIBCPP_HIDE_FROM_ABI
-unsigned __sort4(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3, _ForwardIterator __x4,
+void __sort4(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3, _ForwardIterator __x4,
_Compare __c) {
using _Ops = _IterOps<_AlgPolicy>;
- unsigned __r = std::__sort3<_AlgPolicy, _Compare>(__x1, __x2, __x3, __c);
+ std::__sort3<_AlgPolicy, _Compare>(__x1, __x2, __x3, __c);
if (__c(*__x4, *__x3)) {
_Ops::iter_swap(__x3, __x4);
- ++__r;
if (__c(*__x3, *__x2)) {
_Ops::iter_swap(__x2, __x3);
- ++__r;
if (__c(*__x2, *__x1)) {
_Ops::iter_swap(__x1, __x2);
- ++__r;
}
}
}
- return __r;
}
// stable, 4-10 compares, 0-9 swaps
template <class _AlgPolicy, class _Comp, class _ForwardIterator>
-_LIBCPP_HIDE_FROM_ABI unsigned __sort5(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3,
- _ForwardIterator __x4, _ForwardIterator __x5, _Comp __comp) {
+_LIBCPP_HIDE_FROM_ABI void __sort5(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3,
+ _ForwardIterator __x4, _ForwardIterator __x5, _Comp __comp) {
using _Ops = _IterOps<_AlgPolicy>;
- unsigned __r = std::__sort4<_AlgPolicy, _Comp>(__x1, __x2, __x3, __x4, __comp);
+ std::__sort4<_AlgPolicy, _Comp>(__x1, __x2, __x3, __x4, __comp);
if (__comp(*__x5, *__x4)) {
_Ops::iter_swap(__x4, __x5);
- ++__r;
if (__comp(*__x4, *__x3)) {
_Ops::iter_swap(__x3, __x4);
- ++__r;
if (__comp(*__x3, *__x2)) {
_Ops::iter_swap(__x2, __x3);
- ++__r;
if (__comp(*__x2, *__x1)) {
_Ops::iter_swap(__x1, __x2);
- ++__r;
}
}
}
}
- return __r;
}
// The comparator being simple is a prerequisite for using the branchless optimization.
More information about the libcxx-commits
mailing list