The compiler looses vector capacity information #82801
Open
Description
opened on Mar 5, 2021
In this example:
pub fn test() -> Vec<u32> {
let mut vec = Vec::with_capacity(3);
let mut i = 0;
while i < 3 {
vec.push(32);
i += 1;
}
vec
}
the compiler produces sub-optimal assembly.
https://rust.godbolt.org/z/1T3Knodn8
Activity