Skip to content

Commit 1f82b8f

Browse files
committed
skip unneeded checks against '__bound_sentinel' when advancing iterator
1 parent 80aa52d commit 1f82b8f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

libcxx/include/__iterator/advance.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,14 @@ struct __fn {
170170
} else {
171171
// Otherwise, if `n` is non-negative, while `bool(i != bound_sentinel)` is true, increments `i` but at
172172
// most `n` times.
173-
while (__i != __bound_sentinel && __n > 0) {
173+
while (__n > 0 && __i != __bound_sentinel) {
174174
++__i;
175175
--__n;
176176
}
177177

178178
// Otherwise, while `bool(i != bound_sentinel)` is true, decrements `i` but at most `-n` times.
179179
if constexpr (bidirectional_iterator<_Ip> && same_as<_Ip, _Sp>) {
180-
while (__i != __bound_sentinel && __n < 0) {
180+
while (__n < 0 && __i != __bound_sentinel) {
181181
--__i;
182182
++__n;
183183
}

0 commit comments

Comments
 (0)