Skip to content

Commit e3433e3

Browse files
committed
Fix outdated comment in Vec::from_iter
Since commit 46068c9, call to `reserve()` on empty vec allocates exactly requested capacity, so unroll of first iteration may help only with branch prediction.
1 parent 01fc81f commit e3433e3

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/libcollections/vec.rs

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

0 commit comments

Comments
 (0)