Skip to content

Commit

Permalink
auto merge of #8766 : brson/rust/vecfromfn, r=alexcrichton
Browse files Browse the repository at this point in the history
A recently-enabled test of this is causing valgrind failures.
  • Loading branch information
bors committed Aug 26, 2013
2 parents ce27752 + 8dc13ac commit 9cd91c8
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/libstd/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ use rt::global_heap::realloc_raw;
use sys;
use sys::size_of;
use uint;
use unstable::finally::Finally;
use unstable::intrinsics;
use unstable::intrinsics::{get_tydesc, contains_managed};
use unstable::raw::{Box, Repr, Slice, Vec};
Expand All @@ -97,11 +98,14 @@ pub fn from_fn<T>(n_elts: uint, op: &fn(uint) -> T) -> ~[T] {
let mut v = with_capacity(n_elts);
let p = raw::to_mut_ptr(v);
let mut i: uint = 0u;
while i < n_elts {
intrinsics::move_val_init(&mut(*ptr::mut_offset(p, i as int)), op(i));
i += 1u;
do (|| {
while i < n_elts {
intrinsics::move_val_init(&mut(*ptr::mut_offset(p, i as int)), op(i));
i += 1u;
}
}).finally {
raw::set_len(&mut v, i);
}
raw::set_len(&mut v, n_elts);
v
}
}
Expand Down

0 comments on commit 9cd91c8

Please sign in to comment.