[libcxx-commits] [libcxx] [libc++] Optimize ranges::equal for vector<bool>::iterator (PR #121084)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Feb 5 09:20:49 PST 2025
================
@@ -94,6 +228,32 @@ __equal_impl(_Tp* __first1, _Tp* __last1, _Up* __first2, _Up*, _Pred&, _Proj1&,
return std::__constexpr_memcmp_equal(__first1, __first2, __element_count(__last1 - __first1));
}
+template <class _Cp,
+ bool _IC1,
+ bool _IC2,
+ class _Pred,
+ class _Proj1,
+ class _Proj2,
+ __enable_if_t<(is_same<_Pred, __equal_to>::value
+# if _LIBCPP_STD_VER >= 20
+ || is_same<_Pred, ranges::equal_to>::value
+# endif
+ ) &&
+ __desugars_to_v<__equal_tag, _Pred, bool, bool> && __is_identity<_Proj1>::value &&
+ __is_identity<_Proj2>::value,
----------------
ldionne wrote:
The following should be sufficient:
```suggestion
__enable_if_t<__desugars_to_v<__equal_tag, _Pred, bool, bool> && __is_identity<_Proj1>::value &&
__is_identity<_Proj2>::value,
```
`__desugars_to_v<__equal_tag, ranges::equal_to, ...>` should be true, so the `is_same` are not required. You can confirm that by double-checking that you still get the same speedup in your benchmark after making this change.
https://github.com/llvm/llvm-project/pull/121084
More information about the libcxx-commits
mailing list