auto merge of #5867 : dotdash/rust/reduce_reallocs, r=graydon
The foldl based implementation allocates lots of unneeded vectors. iter::map_to_vec is already optimized to avoid these. One place that benefits quite a lot from this is the metadata decoder, helping with compile times for tiny programs.
This commit is contained in:
commit
8c2e5cceee
1 changed files with 1 additions and 1 deletions
|
@ -161,7 +161,7 @@ pub fn foldl<A,B,IA:BaseIter<A>>(self: &IA, b0: B, blk: &fn(&B, &A) -> B)
|
|||
|
||||
#[inline(always)]
|
||||
pub fn to_vec<A:Copy,IA:BaseIter<A>>(self: &IA) -> ~[A] {
|
||||
foldl::<A,~[A],IA>(self, ~[], |r, a| vec::append(copy (*r), ~[*a]))
|
||||
map_to_vec(self, |&x| x)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
|
Loading…
Reference in a new issue