mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-04 20:54:13 +00:00
stdlib: Make list::from_vec more efficient
This commit is contained in:
parent
d53a253dca
commit
1da99cdf68
@ -26,13 +26,7 @@ Function: from_vec
|
||||
Create a list from a vector
|
||||
*/
|
||||
fn from_vec<T>(v: [mutable? T]) -> list<T> {
|
||||
let l = nil::<T>;
|
||||
// FIXME: This would be faster and more space efficient if it looped over
|
||||
// a reverse vector iterator. Unfortunately generic iterators seem not to
|
||||
// work yet.
|
||||
|
||||
for item: T in vec::reversed(v) { l = cons::<T>(item, @l); }
|
||||
ret l;
|
||||
*vec::foldr({ |h, t| @cons(h, t) }, @nil::<T>, v)
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user