Skip to content

Commit 6652e66

Browse files
committed
Substitute second loop with mismatch
1 parent ef1a6d6 commit 6652e66

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

libcxx/include/__algorithm/is_permutation.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,10 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __is_permutation(
164164
_Proj2&& __proj2,
165165
/*_ConstTimeDistance=*/false_type) {
166166
// Shorten sequences as much as possible by lopping off any equal prefix.
167-
while (__first1 != __last1 && __first2 != __last2) {
168-
if (!std::__invoke(__pred, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2)))
169-
break;
170-
++__first1;
171-
++__first2;
172-
}
167+
auto __result = std::__mismatch(__first1, __last1, __first2, __last2, __pred, __proj1, __proj2);
168+
169+
__first1 = __result.first;
170+
__first2 = __result.second;
173171

174172
if (__first1 == __last1)
175173
return __first2 == __last2;

0 commit comments

Comments
 (0)