Skip to content

Commit

Permalink
Fix outdated comment in Vec::from_iter
Browse files Browse the repository at this point in the history
Since commit 46068c9, call to `reserve()` on empty vec allocates
exactly requested capacity, so unroll of first iteration may help only
with branch prediction.
  • Loading branch information
stepancheg committed Nov 8, 2015
1 parent 01fc81f commit e3433e3
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/libcollections/vec.rs
Expand Up @@ -1220,8 +1220,7 @@ impl<T> FromIterator<T> for Vec<T> {
// expanded on this iteration in every case when the iterable is not
// empty, but the loop in extend_desugared() is not going to see the
// vector being full in the few subsequent loop iterations.
// So we get better branch prediction and the possibility to
// construct the vector with initial estimated capacity.
// So we get better branch prediction.
let mut iterator = iterable.into_iter();
let mut vector = match iterator.next() {
None => return Vec::new(),
Expand Down

0 comments on commit e3433e3

Please sign in to comment.