提交 d1927d29 编写于 作者: B bors

auto merge of #7137 : erickt/rust/from-elem-fixme, r=thestinger

This is to make sure we track optimizing `vec::from_elem`.
...@@ -146,8 +146,10 @@ pub fn from_fn<T>(n_elts: uint, op: old_iter::InitOp<T>) -> ~[T] { ...@@ -146,8 +146,10 @@ pub fn from_fn<T>(n_elts: uint, op: old_iter::InitOp<T>) -> ~[T] {
* to the value `t`. * to the value `t`.
*/ */
pub fn from_elem<T:Copy>(n_elts: uint, t: T) -> ~[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 // FIXME (#7136): manually inline from_fn for 2x plus speedup (sadly very
// bottleneck in borrowck!) // 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 { unsafe {
let mut v = with_capacity(n_elts); let mut v = with_capacity(n_elts);
do as_mut_buf(v) |p, _len| { do as_mut_buf(v) |p, _len| {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册