about summary refs log tree commit diff
path: root/src/librustdoc/scrape_examples.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-09-24 04:04:46 +0000
committerbors <bors@rust-lang.org>2022-09-24 04:04:46 +0000
commit06968954f7e11454d49377629bb57d13253384b9 (patch)
tree561ae3d588c1da030fcd8fe616daf988a9e01893 /src/librustdoc/scrape_examples.rs
parente1c28e0c857280ce829beab16ef6082cd518db98 (diff)
parentdb2b4a3a7e4f75699d767311bf8b49a7c2946892 (diff)
downloadrust-06968954f7e11454d49377629bb57d13253384b9.tar.gz
rust-06968954f7e11454d49377629bb57d13253384b9.zip
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
```
Diffstat (limited to 'src/librustdoc/scrape_examples.rs')
0 files changed, 0 insertions, 0 deletions