Skip to content

Commit 728a000

Browse files
committed
Remove preemptive iterator advancement for better optimizations
1 parent 6652e66 commit 728a000

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

libcxx/include/__algorithm/is_permutation.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// -*- C++ -*-
1+
// -*- C++ -*-
22
//===----------------------------------------------------------------------===//
33
//
44
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
@@ -102,12 +102,11 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __is_permutation_impl(
102102
if (__c2 == 0)
103103
return false;
104104

105-
// Count number of *__i in [__i, l1) (we can start with 1)
105+
// Count number of *__i in [__i, l1)
106106
auto __predicate1 = [&](_Ref1 __x) -> bool {
107107
return std::__invoke(__pred, std::__invoke(__proj1, *__i), std::__invoke(__proj1, __x));
108108
};
109-
auto __start = _IterOps<_AlgPolicy>::next(__i);
110-
_D1 __c1 = 1 + std::__count_if<_AlgPolicy>(__start, __last1, __predicate1, __ident);
109+
_D1 __c1 = std::__count_if<_AlgPolicy>(__i, __last1, __predicate1, __ident);
111110
if (__c1 != __c2)
112111
return false;
113112
}

0 commit comments

Comments
 (0)