Commit 90967c9
fix drop_while work with stateful iterators
Currently, method `drop_while` rewinds the iterator once it yields
values not satisfying the condition. Such approach doesn't work with
stateful iterators since they cannot be rewound by simply copying the
state. The commit brings a new implementation that works correctly with
all types of iterators.
Performance comparison. In the first scenario, functor from `drop_while`
returns `true` on the first million elements, then it returns `false` on
the other million elements. With LuaJIT enabled, the new implementation
is about 7% faster. Without LuaJIT, results are identical. In the second
scenario, we leave only the first half of elements so that functor always
returns `true`, which results in an empty iterator since all the elements
are dropped. In this case, the new implementation is about 10-15% faster
with JIT enabled. In the third scenario, we leave the second half of
elements so that the functor returns `false` right from the start.
In this case, the new implementation is about 4% slower than the old one
with JIT enabled.
Part of #831 parent a52e66e commit 90967c9
2 files changed
+97
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
411 | 411 | | |
412 | 412 | | |
413 | 413 | | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
414 | 432 | | |
415 | | - | |
416 | | - | |
| 433 | + | |
| 434 | + | |
417 | 435 | | |
418 | | - | |
| 436 | + | |
419 | 437 | | |
420 | 438 | | |
421 | 439 | | |
422 | 440 | | |
423 | | - | |
424 | | - | |
425 | | - | |
426 | | - | |
427 | | - | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
428 | 445 | | |
429 | 446 | | |
430 | 447 | | |
431 | | - | |
| 448 | + | |
432 | 449 | | |
433 | 450 | | |
434 | 451 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
0 commit comments