Skip to content

Commit 07e1d1c

Browse files
committed
Improved graph500 performance (Issue #2719)
1 parent e991855 commit 07e1d1c

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

src/libcore/vec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ pure fn from_fn<T>(n_elts: uint, op: init_op<T>) -> [T] {
179179
let mut v = [];
180180
unchecked{reserve(v, n_elts);}
181181
let mut i: uint = 0u;
182-
while i < n_elts { v += [op(i)]; i += 1u; }
182+
while i < n_elts unsafe { push(v, op(i)); i += 1u; }
183183
ret v;
184184
}
185185

@@ -564,7 +564,7 @@ Apply a function to each element of a vector and return the results
564564
pure fn mapi<T, U>(v: [T]/&, f: fn(uint, T) -> U) -> [U] {
565565
let mut result = [];
566566
unchecked{reserve(result, len(v));}
567-
for eachi(v) {|i, elem| result += [f(i, elem)]; }
567+
for eachi(v) {|i, elem| unsafe { push(result, f(i, elem)); } }
568568
ret result;
569569
}
570570

src/libstd/par.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fn map_slices<A: copy send, B: copy send>(
4242
// FIXME: why is the ::<A, ()> annotation required here? (#2617)
4343
vec::unpack_slice::<A, ()>(xs) {|p, _len|
4444
let f = f();
45-
futures += [future::spawn() {|copy base|
45+
let f = future::spawn() {|copy base|
4646
unsafe {
4747
let len = end - base;
4848
let slice = (ptr::offset(p, base),
@@ -55,7 +55,8 @@ fn map_slices<A: copy send, B: copy send>(
5555
assert(vec::len(slice) == end - base);
5656
f(base, slice)
5757
}
58-
}];
58+
};
59+
vec::push(futures, f);
5960
};
6061
base += items_per_task;
6162
}

src/test/bench/graph500-bfs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ fn validate(edges: [(node_id, node_id)],
305305
status = false;
306306
}
307307

308-
path += [parent];
308+
vec::push(path, parent);
309309
parent = tree[parent];
310310
}
311311

0 commit comments

Comments
 (0)