Skip to content

Commit 4675f86

Browse files
committed
rustdoc: Do less copying in util::parmap
1 parent 222cfbe commit 4675f86

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/rustdoc/util.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
export parmap;
22

3-
fn parmap<T:send, U:send>(v: [T], f: fn~(T) -> U) -> [U] {
3+
fn parmap<T:send, U:send>(v: [T], f: fn~(T) -> U) -> [U] unsafe {
44
let futures = vec::map(v) {|elt|
5-
future::spawn {||
6-
f(elt)
5+
let po = comm::port();
6+
let ch = comm::chan(po);
7+
let addr = ptr::addr_of(elt);
8+
task::spawn {||
9+
comm::send(ch, f(*addr));
710
}
11+
po
812
};
913
vec::map(futures) {|future|
10-
future::get(future)
14+
comm::recv(future)
1115
}
1216
}
1317

0 commit comments

Comments
 (0)