You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Auto merge of rust-lang#116568 - kornelski:hint-reserved, r=<try>
Hint optimizer about reserved capacity
The fact that `Vec` had capacity increased is not known to the optimizer, because functions like `do_reserve_and_handle` are not inlined. Because of that, code such as:
```rust
vec.try_reserve(123)?;
vec.extend_from_slice(&s[..123]);
```
Tries to reserve the capacity **twice**. This is unnecessary code bloat.
https://rust.godbolt.org/z/YWY16Ezej
Adding a hint after reserve optimizes out the next check of `self.needs_to_grow(len, additional)`.
0 commit comments