diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-07-01 06:46:30 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-07-01 06:46:30 +1000 |
| commit | 679c5ee244f997a563af45e335681e16fc089b34 (patch) | |
| tree | e101d6317e6f66f03bc70deffbc9ca3a5665b3eb /compiler/rustc_codegen_llvm/src | |
| parent | ddcbba036aee08f0709f98a92a342a278eae5c05 (diff) | |
| download | rust-679c5ee244f997a563af45e335681e16fc089b34.tar.gz rust-679c5ee244f997a563af45e335681e16fc089b34.zip | |
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.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
0 files changed, 0 insertions, 0 deletions
