diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-11-08 11:23:50 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-08 11:23:50 +0530 |
| commit | b695ed3f2032d349a5cb9f26a8df67936943c075 (patch) | |
| tree | 761258b611d0c454802f4b70edbe18aeee4d8119 /tests/codegen/src-hash-algorithm/src-hash-algorithm-sha256.rs | |
| parent | 6184a963f71f934f43fb75ca7effd656b23cd9f8 (diff) | |
| parent | 3925fc0c8e0b4ad9be48fbc1136281841d8985fa (diff) | |
| download | rust-b695ed3f2032d349a5cb9f26a8df67936943c075.tar.gz rust-b695ed3f2032d349a5cb9f26a8df67936943c075.zip | |
Rollup merge of #103446 - the8472:tra-array-chunks, r=Mark-Simulacrum
Specialize `iter::ArrayChunks::fold` for TrustedRandomAccess iterators ``` OLD: test iter::bench_trusted_random_access_chunks ... bench: 368 ns/iter (+/- 4) NEW: test iter::bench_trusted_random_access_chunks ... bench: 30 ns/iter (+/- 0) ``` The resulting assembly is similar to #103166 but the specialization kicks in under different (partially overlapping) conditions compared to that PR. They're complementary. In principle a TRA-based specialization could be applied to all `ArrayChunks` methods, including `next()` as we do for `Zip` but that would have all the same hazards as the Zip specialization. Only doing it for `fold` is far less hazardous. The downside is that it only helps with internal, exhaustive iteration. I.e. `for _ in` or `try_fold` will not benefit. Note that the regular, `try_fold`-based and the specialized `fold()` impl have observably slightly different behavior. Namely the specialized variant does not fetch the remainder elements from the underlying iterator. We do have a few other places in the standard library where beyond-the-end-of-iteration side-effects are being elided under some circumstances but not others. Inspired by https://old.reddit.com/r/rust/comments/yaft60/zerocost_iterator_abstractionsnot_so_zerocost/
Diffstat (limited to 'tests/codegen/src-hash-algorithm/src-hash-algorithm-sha256.rs')
0 files changed, 0 insertions, 0 deletions
