rust/library/alloc
Nicholas Nethercote 679c5ee244 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.
2022-07-01 06:46:30 +10:00
..
benches Add VecDeque::extend TrustedLen benchmark 2022-06-17 23:41:03 +02:00
src Optimize Vec::insert for the case where index == len. 2022-07-01 06:46:30 +10:00
tests liballoc tests: avoid int2ptr cast 2022-06-27 10:50:56 -04:00
Cargo.toml Switch all libraries to the 2021 edition 2021-12-23 19:03:47 +08:00