Skip to content

Commit 17d604f

Browse files
committed
Rollup merge of rust-lang#29688 - stepancheg:vec-outdated, r=nikomatsakis
Since commit 46068c9, call to `reserve()` on empty vec allocates exactly requested capacity, so unroll of first iteration may help only with branch prediction.
2 parents 1011f8e + e3433e3 commit 17d604f

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/libcollections/vec.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,8 +1221,7 @@ impl<T> FromIterator<T> for Vec<T> {
12211221
// expanded on this iteration in every case when the iterable is not
12221222
// empty, but the loop in extend_desugared() is not going to see the
12231223
// vector being full in the few subsequent loop iterations.
1224-
// So we get better branch prediction and the possibility to
1225-
// construct the vector with initial estimated capacity.
1224+
// So we get better branch prediction.
12261225
let mut iterator = iterable.into_iter();
12271226
let mut vector = match iterator.next() {
12281227
None => return Vec::new(),

0 commit comments

Comments
 (0)