[libcxx-commits] [libcxx] [libc++] Optimize rotate (PR #120890)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Dec 18 09:14:49 PST 2025
================
@@ -89,46 +86,39 @@ __rotate_forward(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIt
return __r;
}
-template <typename _Integral>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 _Integral __algo_gcd(_Integral __x, _Integral __y) {
- do {
- _Integral __t = __x % __y;
- __x = __y;
- __y = __t;
- } while (__y);
- return __x;
-}
+template <class _AlgPolicy, class _Iter, class _Sent>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 _Iter __rotate_random(_Iter __first, _Iter __middle, _Sent __last) {
----------------
ldionne wrote:
```suggestion
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 _Iter __rotate_random(_Iter __first, _Iter __middle, _Sent __sent) {
```
And then rename `__end` to `__last` just cause it's easier to follow.
https://github.com/llvm/llvm-project/pull/120890
More information about the libcxx-commits
mailing list