@@ -34,7 +34,7 @@ use unstable::intrinsics;
34
34
#[ cfg( stage0) ]
35
35
use intrinsic:: { get_tydesc} ;
36
36
#[ cfg( not( stage0) ) ]
37
- use unstable:: intrinsics:: { get_tydesc} ;
37
+ use unstable:: intrinsics:: { get_tydesc, contains_managed } ;
38
38
use vec;
39
39
use util;
40
40
@@ -1521,6 +1521,7 @@ impl<T> OwnedVector<T> for ~[T] {
1521
1521
* * n - The number of elements to reserve space for
1522
1522
*/
1523
1523
#[ inline]
1524
+ #[ cfg( stage0) ]
1524
1525
fn reserve( & mut self , n: uint) {
1525
1526
// Only make the (slow) call into the runtime if we have to
1526
1527
use managed;
@@ -1538,6 +1539,33 @@ impl<T> OwnedVector<T> for ~[T] {
1538
1539
}
1539
1540
}
1540
1541
1542
+ /**
1543
+ * Reserves capacity for exactly `n` elements in the given vector.
1544
+ *
1545
+ * If the capacity for `self` is already equal to or greater than the requested
1546
+ * capacity, then no action is taken.
1547
+ *
1548
+ * # Arguments
1549
+ *
1550
+ * * n - The number of elements to reserve space for
1551
+ */
1552
+ #[ inline]
1553
+ #[ cfg( not( stage0) ) ]
1554
+ fn reserve( & mut self , n: uint) {
1555
+ // Only make the (slow) call into the runtime if we have to
1556
+ if self . capacity( ) < n {
1557
+ unsafe {
1558
+ let ptr: * * raw :: VecRepr = cast:: transmute( self ) ;
1559
+ let td = get_tydesc :: < T > ( ) ;
1560
+ if contains_managed :: < T > ( ) {
1561
+ rustrt:: vec_reserve_shared_actual( td, ptr, n as libc:: size_t) ;
1562
+ } else {
1563
+ rustrt:: vec_reserve_shared( td, ptr, n as libc:: size_t) ;
1564
+ }
1565
+ }
1566
+ }
1567
+ }
1568
+
1541
1569
/**
1542
1570
* Reserves capacity for at least `n` elements in the given vector.
1543
1571
*
0 commit comments