06968954f7
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 ``` |
||
---|---|---|
.. | ||
benches | ||
primitive_docs | ||
src | ||
tests | ||
Cargo.toml |