Uh oh!
There was an error while loading. Please reload this page.
Optimise Iterator::{max, max_by, min, min_by}. - #24180
Conversation
rust-highfive
commented
Apr 8, 2015
r? @pcwalton (rust_highfive has picked a reviewer for you, use r? to override) |
There was a problem hiding this comment.
Is there some reason the comparison function takes 4 arguments, when each client only wants 2 of them, instead of just making it take the projections and having max() / min() use |x| x for the projection function?
There was a problem hiding this comment.
I agree it would be nice but the lifetimes don't work out, B is disconnected from &I::Item. I think the fact we move sel and x around internally means that this approach can't work. :(
alexcrichton
commented
Apr 9, 2015
r=me with nits addressed, nice wins! |
The main change in this patch is removing the use of `Option` inside the inner loops of those functions to avoid comparisons where one branch will only trigger on the first pass through the loop. The included benchmarks go from: test bench_max ... bench: 372 ns/iter (+/- 118) test bench_max_by ... bench: 428 ns/iter (+/- 33) test bench_max_by2 ... bench: 7128 ns/iter (+/- 326) to: test bench_max ... bench: 317 ns/iter (+/- 64) test bench_max_by ... bench: 356 ns/iter (+/- 270) test bench_max_by2 ... bench: 1387 ns/iter (+/- 183) Problem noticed in http://www.reddit.com/r/rust/comments/31syce/using_iterators_to_find_the_index_of_the_min_or/
huonw
commented
Apr 10, 2015
@bors r=alexcrichton |
bors
commented
Apr 10, 2015
📌 Commit c2258d6 has been approved by |
bors
commented
Apr 10, 2015
⌛ Testing commit c2258d6 with merge f4aa02e... |
The main change in this patch is removing the use of `Option` inside the inner loops of those functions to avoid comparisons where one branch will only trigger on the first pass through the loop. The included benchmarks go from: test bench_max ... bench: 372 ns/iter (+/- 118) test bench_max_by ... bench: 428 ns/iter (+/- 33) test bench_max_by2 ... bench: 7128 ns/iter (+/- 326) to: test bench_max ... bench: 317 ns/iter (+/- 64) test bench_max_by ... bench: 356 ns/iter (+/- 270) test bench_max_by2 ... bench: 1387 ns/iter (+/- 183) Problem noticed in http://www.reddit.com/r/rust/comments/31syce/using_iterators_to_find_the_index_of_the_min_or/
bors
commented
Apr 10, 2015
⛄ The build was interrupted to prioritize another pull request. |
bors
commented
Apr 10, 2015
⌛ Testing commit c2258d6 with merge 1302028... |
The main change in this patch is removing the use of `Option` inside the inner loops of those functions to avoid comparisons where one branch will only trigger on the first pass through the loop. The included benchmarks go from: test bench_max ... bench: 372 ns/iter (+/- 118) test bench_max_by ... bench: 428 ns/iter (+/- 33) test bench_max_by2 ... bench: 7128 ns/iter (+/- 326) to: test bench_max ... bench: 317 ns/iter (+/- 64) test bench_max_by ... bench: 356 ns/iter (+/- 270) test bench_max_by2 ... bench: 1387 ns/iter (+/- 183) Problem noticed in http://www.reddit.com/r/rust/comments/31syce/using_iterators_to_find_the_index_of_the_min_or/
bors
commented
Apr 10, 2015
⛄ The build was interrupted to prioritize another pull request. |
bors
commented
Apr 10, 2015
The main change in this patch is removing the use of `Option` inside the inner loops of those functions to avoid comparisons where one branch will only trigger on the first pass through the loop. The included benchmarks go from: test bench_max ... bench: 372 ns/iter (+/- 118) test bench_max_by ... bench: 428 ns/iter (+/- 33) test bench_max_by2 ... bench: 7128 ns/iter (+/- 326) to: test bench_max ... bench: 317 ns/iter (+/- 64) test bench_max_by ... bench: 356 ns/iter (+/- 270) test bench_max_by2 ... bench: 1387 ns/iter (+/- 183) Problem noticed in http://www.reddit.com/r/rust/comments/31syce/using_iterators_to_find_the_index_of_the_min_or/
The main change in this patch is removing the use of
Optioninside theinner loops of those functions to avoid comparisons where one branch
will only trigger on the first pass through the loop.
The included benchmarks go from:
to:
Problem noticed in http://www.reddit.com/r/rust/comments/31syce/using_iterators_to_find_the_index_of_the_min_or/