[libcxx-commits] [libcxx] [libc++][ranges] optimize the performance of `ranges::starts_with` (PR #84570)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Fri Apr 26 07:49:11 PDT 2024


================
@@ -69,18 +95,41 @@ struct __fn {
     requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2>
   _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI static constexpr bool
   operator()(_Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) {
-    return __mismatch::__fn::__go(
+    if constexpr (sized_range<_Range1> && sized_range<_Range2>) {
----------------
ldionne wrote:

Why don't we call `(*this)(ranges::begin(__range1), ranges::end(__range1), ranges::begin(__range2), ranges::end(__range2), pred, proj1, proj2)` instead? Did I miss anything subtle?

https://github.com/llvm/llvm-project/pull/84570


More information about the libcxx-commits mailing list