about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-07-03 09:36:37 +0000
committerbors <bors@rust-lang.org>2022-07-03 09:36:37 +0000
commitf99f9e48ed77a99747c6d07b42fdfe500f1a7de0 (patch)
tree049ae0507ab329ca285c127d1555c7d48d0b62bc /compiler/rustc_codegen_llvm/src
parentada8c80bedb713b320af00aacab97d01d9cb5933 (diff)
parent679c5ee244f997a563af45e335681e16fc089b34 (diff)
downloadrust-f99f9e48ed77a99747c6d07b42fdfe500f1a7de0.tar.gz
rust-f99f9e48ed77a99747c6d07b42fdfe500f1a7de0.zip
Auto merge of #98755 - nnethercote:faster-vec-insert, r=cuviper
Optimize `Vec::insert` for the case where `index == len`.

By skipping the call to `copy` with a zero length. This makes it closer
to `push`.

I did this recently for `SmallVec`
(https://github.com/servo/rust-smallvec/pull/282) and it was a big perf win in
one case. Although I don't have a specific use case in mind, it seems
worth doing it for `Vec` as well.

Things to note:
- In the `index < len` case, the number of conditions checked is
  unchanged.
- In the `index == len` case, the number of conditions checked increases
  by one, but the more expensive zero-length copy is avoided.
- In the `index > len` case the code now reserves space for the extra
  element before panicking. This seems like an unimportant change.

r? `@cuviper`
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
0 files changed, 0 insertions, 0 deletions