Skip to content

Commit 3411d19

Browse files
committed
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.
1 parent affd83e commit 3411d19

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/libcore/vec.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,13 +409,14 @@ fn pop<T>(&v: [const T]) -> T unsafe {
409409
val
410410
}
411411

412+
#[inline]
412413
/*
413414
Function: push
414415
415-
Append an element to a vector and return it
416+
Append an element to a vector
416417
*/
417418
fn push<T: copy>(&v: [T], initval: T) {
418-
grow(v, 1u, initval)
419+
v += [initval];
419420
}
420421

421422
// TODO: More.

0 commit comments

Comments
 (0)