rust/library
bors 2cec6874c0 Auto merge of #98004 - paolobarbolini:vecdeque-extend-trustedlen, r=the8472
Add VecDeque::extend from TrustedLen specialization

Continuation of #95904

Inspired by how [`VecDeque::copy_slice` works](c08b235a5c/library/alloc/src/collections/vec_deque/mod.rs (L437-L454)).

## Benchmarks

Before

```
test vec_deque::bench_extend_chained_bytes      ... bench:       1,026 ns/iter (+/- 17)
test vec_deque::bench_extend_chained_trustedlen ... bench:       1,024 ns/iter (+/- 40)
test vec_deque::bench_extend_trustedlen         ... bench:         637 ns/iter (+/- 693)
```

After

```
test vec_deque::bench_extend_chained_bytes      ... bench:         828 ns/iter (+/- 24)
test vec_deque::bench_extend_chained_trustedlen ... bench:          25 ns/iter (+/- 1)
test vec_deque::bench_extend_trustedlen         ... bench:          21 ns/iter (+/- 0)
```

## Why do it this way

https://rust.godbolt.org/z/15qY1fMYh

The Compiler Explorer example shows how "just" removing the capacity check, like the [`Vec` `TrustedLen` specialization](c08b235a5c/library/alloc/src/vec/spec_extend.rs (L22-L58)) does, wouldn't have been enough for `VecDeque`. `wrap_add` would still have greatly limited what LLVM could do while optimizing.

---

r? `@the8472`
2022-06-18 12:54:01 +00:00
..
alloc Auto merge of #98004 - paolobarbolini:vecdeque-extend-trustedlen, r=the8472 2022-06-18 12:54:01 +00:00
backtrace@4e5a3f7292 update libbacktrace 2022-05-20 09:30:26 +02:00
core Expose iter::ByRefSized as unstable feature and use it 2022-06-18 00:03:54 +02:00
panic_abort Fully stabilize NLL 2022-06-03 17:16:41 -04:00
panic_unwind Add underscores to rust_eh_personality arguments to mark them as unused 2022-06-09 09:50:26 -07:00
portable-simd Finish bumping stage0 2022-05-27 07:36:17 -04:00
proc_macro review fixups 2022-06-17 22:10:07 -04:00
profiler_builtins Fully stabilize NLL 2022-06-03 17:16:41 -04:00
rtstartup
rustc-std-workspace-alloc Switch all libraries to the 2021 edition 2021-12-23 19:03:47 +08:00
rustc-std-workspace-core Switch all libraries to the 2021 edition 2021-12-23 19:03:47 +08:00
rustc-std-workspace-std Switch all libraries to the 2021 edition 2021-12-23 19:03:47 +08:00
std Impl Termination for Infallible and then make the Result impls of Termination into a blanket 2022-06-17 13:54:17 -04:00
stdarch@28335054b1 Also allow unused macro rules in stdarch 2022-05-10 19:53:22 +02:00
test Fully stabilize NLL 2022-06-03 17:16:41 -04:00
unwind Stabilize the bundle native library modifier 2022-06-09 23:12:58 +04:00