[libcxx-commits] [libcxx] [libc++] [sort] Improve perfomance of std::sort (PR #76616)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Dec 30 06:37:01 PST 2023
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 81cedac8f60cf5a0c2c3724a8260d46792b9d637 c337b96a75ce366388eac318ccfb5a2e0b43a6a8 -- libcxx/include/__algorithm/sort.h libcxx/test/libcxx/algorithms/sort_stability.pass.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/libcxx/include/__algorithm/sort.h b/libcxx/include/__algorithm/sort.h
index 9e72d460f0..d30e394e98 100644
--- a/libcxx/include/__algorithm/sort.h
+++ b/libcxx/include/__algorithm/sort.h
@@ -159,7 +159,7 @@ inline _LIBCPP_HIDE_FROM_ABI void __cond_swap(_RandomAccessIterator __x, _Random
// Note: this function behaves correctly even with proxy iterators (because it relies on `value_type`).
using value_type = typename iterator_traits<_RandomAccessIterator>::value_type;
static_assert(is_trivially_copyable<value_type>::value, "");
- bool __r = __c(*__x, *__y);
+ bool __r = __c(*__x, *__y);
value_type __tmp = __r ? *__x : *__y;
*__y = __r ? *__y : *__x;
*__x = __tmp;
@@ -173,7 +173,7 @@ __partially_sorted_swap(_RandomAccessIterator __x, _RandomAccessIterator __y, _R
// Note: this function behaves correctly even with proxy iterators (because it relies on `value_type`).
using value_type = typename iterator_traits<_RandomAccessIterator>::value_type;
static_assert(is_trivially_copyable<value_type>::value, "");
- bool __r = __c(*__z, *__x);
+ bool __r = __c(*__z, *__x);
value_type __tmp = __r ? *__z : *__x;
*__z = __r ? *__x : *__z;
__r = __c(__tmp, *__y);
``````````
</details>
https://github.com/llvm/llvm-project/pull/76616
More information about the libcxx-commits
mailing list