rust/library
bors c24c9067ee Auto merge of #88060 - TennyZhuang:optimize-vec-retain, r=dtolnay
Optimize unnecessary check in Vec::retain

The function `vec::Vec::retain` only have two stages:

1. Nothing was deleted.
2. Some elements were deleted.

Here is an unnecessary check `if g.deleted_cnt > 0` in the loop, and it's difficult for compiler to optimize it. I split the loop into two stages manully and keep the code clean using const generics.

I write a special but common bench case for this optimization. I call retain on vec but keep all elements.

Before and after this optimization:

```
test vec::bench_retain_whole_100000                      ... bench:      84,803 ns/iter (+/- 17,314)
```

```
test vec::bench_retain_whole_100000                      ... bench:      42,638 ns/iter (+/- 16,910)
```

The result is expected, there are two `if`s before the optimization and one `if` after.
2021-10-03 06:24:06 +00:00
..
alloc Auto merge of #88060 - TennyZhuang:optimize-vec-retain, r=dtolnay 2021-10-03 06:24:06 +00:00
backtrace@cc89bb66f9 Update the backtrace crate 2021-09-15 20:32:35 +02:00
core Make diangostic item names consistent 2021-10-02 19:38:19 -05:00
panic_abort Add SOLID targets 2021-09-28 11:31:47 +09:00
panic_unwind Add SOLID targets 2021-09-28 11:31:47 +09:00
proc_macro Rollup merge of #86165 - m-ou-se:proc-macro-span-shrink, r=dtolnay 2021-09-10 08:23:14 -07:00
profiler_builtins rfc3052: Remove authors field from Cargo manifests 2021-07-29 14:56:05 -07:00
rtstartup Bump bootstrap compiler to 1.50 beta 2020-12-30 09:27:19 -05:00
rustc-std-workspace-alloc rfc3052: Remove authors field from Cargo manifests 2021-07-29 14:56:05 -07:00
rustc-std-workspace-core rfc3052: Remove authors field from Cargo manifests 2021-07-29 14:56:05 -07:00
rustc-std-workspace-std rfc3052: Remove authors field from Cargo manifests 2021-07-29 14:56:05 -07:00
std Make diangostic item names consistent 2021-10-02 19:38:19 -05:00
stdarch@5fdbc476af Update stdarch submodule 2021-09-21 11:24:08 +02:00
test Rollup merge of #89235 - yaahc:junit-formatting, r=kennytm 2021-09-28 20:00:15 +02:00
unwind Add SOLID targets 2021-09-28 11:31:47 +09:00