Skip to content

Commit ac83f4b

Browse files
committed
std: add a fixme to note performance issues in vec::from_elem.
1 parent eadd83d commit ac83f4b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/libstd/vec.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,10 @@ pub fn from_fn<T>(n_elts: uint, op: old_iter::InitOp<T>) -> ~[T] {
155155
* to the value `t`.
156156
*/
157157
pub fn from_elem<T:Copy>(n_elts: uint, t: T) -> ~[T] {
158-
// hack: manually inline from_fn for 2x plus speedup (sadly very important, from_elem is a
159-
// bottleneck in borrowck!)
158+
// FIXME (#7136): manually inline from_fn for 2x plus speedup (sadly very
159+
// important, from_elem is a bottleneck in borrowck!). Unfortunately it
160+
// still is substantially slower than using the unsafe
161+
// vec::with_capacity/ptr::set_memory for primitive types.
160162
unsafe {
161163
let mut v = with_capacity(n_elts);
162164
do as_mut_buf(v) |p, _len| {

0 commit comments

Comments
 (0)