Skip to content

Commit

Permalink
auto merge of #7137 : erickt/rust/from-elem-fixme, r=thestinger
Browse files Browse the repository at this point in the history
This is to make sure we track optimizing `vec::from_elem`.
  • Loading branch information
bors committed Jun 16, 2013
2 parents f74e193 + ac83f4b commit d1927d2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/libstd/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,10 @@ pub fn from_fn<T>(n_elts: uint, op: old_iter::InitOp<T>) -> ~[T] {
* to the value `t`.
*/
pub fn from_elem<T:Copy>(n_elts: uint, t: T) -> ~[T] {
// hack: manually inline from_fn for 2x plus speedup (sadly very important, from_elem is a
// bottleneck in borrowck!)
// FIXME (#7136): manually inline from_fn for 2x plus speedup (sadly very
// important, from_elem is a bottleneck in borrowck!). Unfortunately it
// still is substantially slower than using the unsafe
// vec::with_capacity/ptr::set_memory for primitive types.
unsafe {
let mut v = with_capacity(n_elts);
do as_mut_buf(v) |p, _len| {
Expand Down

0 comments on commit d1927d2

Please sign in to comment.