Signed 64-bit division is much slower than unsigned, so cast the n and
k values to unsigned before doing n %= k. We know this is safe because
neither value can be negative.
libstdc++-v3/ChangeLog:
PR libstdc++/113811
* include/bits/stl_algo.h (__rotate): Use unsigned values for
division.
typedef typename iterator_traits<_RandomAccessIterator>::value_type
_ValueType;
+#if __cplusplus >= 201103L
+ typedef typename make_unsigned<_Distance>::type _UDistance;
+#else
+ typedef _Distance _UDistance;
+#endif
+
_Distance __n = __last - __first;
_Distance __k = __middle - __first;
++__p;
++__q;
}
- __n %= __k;
+ __n = static_cast<_UDistance>(__n) % static_cast<_UDistance>(__k);
if (__n == 0)
return __ret;
std::swap(__n, __k);
--__q;
std::iter_swap(__p, __q);
}
- __n %= __k;
+ __n = static_cast<_UDistance>(__n) % static_cast<_UDistance>(__k);
if (__n == 0)
return __ret;
std::swap(__n, __k);