Use repeat_n in Vec::extend_with#155928
Conversation
|
rustbot has assigned @Mark-Simulacrum. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
4361e93 to
88833cf
Compare
|
r? scottmcm |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Use repeat_n in Vec::extend_with
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (4ac3534): comparison URL. Overall result: ❌✅ regressions and improvements - please read:Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf. Next, please: If you can, justify the regressions found in this try perf run in writing along with @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 0.1%, secondary -0.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 12.6%, secondary -1.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary 0.7%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 482.686s -> 483.185s (0.10%) |
Simplify
Vec::extend_withto useextend(repeat_n(...)). This delegates toextend_trustedwhich essentially does the same thing but using a single loop; the "don't clone the last element" logic is handled inside of therepeat_niterator.This generates slightly better code by removing the manual store of the last element: https://godbolt.org/z/TG6GPY9Eh