Skip to content

Commit 2208cd7

Browse files
committed
Auto merge of #100845 - timvermeulen:iter_compare, r=scottmcm
Use internal iteration in `Iterator` comparison methods Updates the `Iterator` methods `cmp_by`, `partial_cmp_by`, and `eq_by` to use internal iteration on `self`. I've also extracted their shared logic into a private helper function `iter_compare`, which will either short-circuit once the comparison result is known or return the comparison of the lengths of the iterators. This change also indirectly benefits calls to `cmp`, `partial_cmp`, `eq`, `lt`, `le`, `gt`, and `ge`. Unsurprising benchmark results: iterators that benefit from internal iteration (like `Chain`) see a speedup, while other iterators are unaffected. ``` name before ns/iter after ns/iter diff ns/iter diff % speedup iter::bench_chain_partial_cmp 208,301 54,978 -153,323 -73.61% x 3.79 iter::bench_partial_cmp 55,527 55,702 175 0.32% x 1.00 iter::bench_lt 55,502 55,322 -180 -0.32% x 1.00 ```
2 parents 6135e07 + 914d880 commit 2208cd7

File tree

0 file changed

+0
-0
lines changed

    0 file changed

    +0
    -0
    lines changed

    0 commit comments

    Comments
     (0)