diff options
| author | bors <bors@rust-lang.org> | 2022-06-18 12:54:01 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-06-18 12:54:01 +0000 |
| commit | 2cec6874c086a8fa107115dcca73d93228a3bef6 (patch) | |
| tree | 23718b308fa21d0bab0b7bc0406cf207ba0e1a71 /compiler/rustc_parse/src/parser/expr.rs | |
| parent | cdcc53b7dc002ea4a7a28105010c5a1126ee31b7 (diff) | |
| parent | ce3b6f505ed8c0a285461f4f9b729b62e7703354 (diff) | |
| download | rust-2cec6874c086a8fa107115dcca73d93228a3bef6.tar.gz rust-2cec6874c086a8fa107115dcca73d93228a3bef6.zip | |
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](https://github.com/rust-lang/rust/blob/c08b235a5ce10167632bb0fddcd0c5d67f2d42e3/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](https://github.com/rust-lang/rust/blob/c08b235a5ce10167632bb0fddcd0c5d67f2d42e3/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`
Diffstat (limited to 'compiler/rustc_parse/src/parser/expr.rs')
0 files changed, 0 insertions, 0 deletions
