[libcxx-commits] [PATCH] D144478: [libc++][NFC] Simplify __sort{4, 5}
Nikolas Klauser via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Feb 21 10:42:29 PST 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG811b5f52adcb: [libc++][NFC] Simplify __sort{4,5} (authored by philnik).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D144478/new/
https://reviews.llvm.org/D144478
Files:
libcxx/include/__algorithm/sort.h
Index: libcxx/include/__algorithm/sort.h
===================================================================
--- libcxx/include/__algorithm/sort.h
+++ libcxx/include/__algorithm/sort.h
@@ -85,50 +85,41 @@
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144478.499233.patch
Type: text/x-patch
Size: 2204 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230221/f8ad9a2c/attachment-0001.bin>
More information about the libcxx-commits
mailing list