Skip to content

Commit 5ce3d35

Browse files
committed
rustc: Don't zero out arena chunks with vec::from_elem; that's slow because it calls the glue.
1 parent 2663018 commit 5ce3d35

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/libstd/arena.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ type chunk = {data: [u8], mut fill: uint};
88
type arena = {mut chunks: list::list<@chunk>};
99

1010
fn chunk(size: uint) -> @chunk {
11-
@{ data: vec::from_elem(size, 0u8), mut fill: 0u }
11+
let mut v = [];
12+
vec::reserve(v, size);
13+
@{ data: v, mut fill: 0u }
1214
}
1315

1416
fn arena_with_size(initial_size: uint) -> arena {

0 commit comments

Comments
 (0)