Commit 78ca1bd
committed
Auto merge of #62473 - timvermeulen:is_sorted_by_key, r=scottmcm
Only call the closure parameter of Iterator::is_sorted_by_key once per item
See #53485 (comment).
This changes `Iterator::is_sorted_by_key` to only call the given closure once for each item, which allows us to pass the items to the closure by value instead of by reference.
**Important**: `is_sorted_by_key` for slices and slice iterators is now no longer implemented in terms of the custom `slice::Iter::is_sorted_by` implementation. It's a trade-off: we could forward `slice::Iter::is_sorted_by_key` to it directly for potential SIMD benefits, but that would mean that the closure is potentially called twice for (almost) every element of the slice.2 files changed
+5
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2572 | 2572 | | |
2573 | 2573 | | |
2574 | 2574 | | |
2575 | | - | |
| 2575 | + | |
2576 | 2576 | | |
2577 | 2577 | | |
2578 | | - | |
| 2578 | + | |
2579 | 2579 | | |
2580 | 2580 | | |
2581 | | - | |
| 2581 | + | |
2582 | 2582 | | |
2583 | 2583 | | |
2584 | 2584 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2459 | 2459 | | |
2460 | 2460 | | |
2461 | 2461 | | |
2462 | | - | |
| 2462 | + | |
2463 | 2463 | | |
2464 | 2464 | | |
2465 | 2465 | | |
2466 | 2466 | | |
2467 | | - | |
| 2467 | + | |
2468 | 2468 | | |
2469 | 2469 | | |
2470 | 2470 | | |
| |||
0 commit comments