core: Make vec::push faster
This way makes it equivalent to the compiler's vec push, and is a lot faster than calling vec::grow.
This commit is contained in:
@@ -409,13 +409,14 @@ fn pop<T>(&v: [const T]) -> T unsafe {
|
|||||||
val
|
val
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
/*
|
/*
|
||||||
Function: push
|
Function: push
|
||||||
|
|
||||||
Append an element to a vector and return it
|
Append an element to a vector
|
||||||
*/
|
*/
|
||||||
fn push<T: copy>(&v: [T], initval: T) {
|
fn push<T: copy>(&v: [T], initval: T) {
|
||||||
grow(v, 1u, initval)
|
v += [initval];
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: More.
|
// TODO: More.
|
||||||
|
|||||||
Reference in New Issue
Block a user