@@ -116,18 +116,12 @@ use ptr::to_unsafe_ptr;
116
116
use ptr;
117
117
use ptr:: RawPtr ;
118
118
use rt:: global_heap:: { malloc_raw, realloc_raw, exchange_free} ;
119
- #[ cfg( stage0) ]
120
- use rt:: local_heap:: local_free;
121
119
use mem;
122
120
use mem:: size_of;
123
121
use uint;
124
122
use unstable:: finally:: Finally ;
125
123
use unstable:: intrinsics;
126
- #[ cfg( stage0) ]
127
- use unstable:: intrinsics:: { get_tydesc, owns_managed} ;
128
124
use unstable:: raw:: { Repr , Slice , Vec } ;
129
- #[ cfg( stage0) ]
130
- use unstable:: raw:: Box ;
131
125
use util;
132
126
133
127
/**
@@ -182,30 +176,6 @@ pub fn from_elem<T:Clone>(n_elts: uint, t: T) -> ~[T] {
182
176
183
177
/// Creates a new vector with a capacity of `capacity`
184
178
#[ inline]
185
- #[ cfg( stage0) ]
186
- pub fn with_capacity < T > ( capacity : uint ) -> ~[ T ] {
187
- unsafe {
188
- if owns_managed :: < T > ( ) {
189
- let mut vec = ~[ ] ;
190
- vec. reserve ( capacity) ;
191
- vec
192
- } else {
193
- let alloc = capacity * mem:: nonzero_size_of :: < T > ( ) ;
194
- let size = alloc + mem:: size_of :: < Vec < ( ) > > ( ) ;
195
- if alloc / mem:: nonzero_size_of :: < T > ( ) != capacity || size < alloc {
196
- fail ! ( "vector size is too large: {}" , capacity) ;
197
- }
198
- let ptr = malloc_raw ( size) as * mut Vec < ( ) > ;
199
- ( * ptr) . alloc = alloc;
200
- ( * ptr) . fill = 0 ;
201
- cast:: transmute ( ptr)
202
- }
203
- }
204
- }
205
-
206
- /// Creates a new vector with a capacity of `capacity`
207
- #[ inline]
208
- #[ cfg( not( stage0) ) ]
209
179
pub fn with_capacity < T > ( capacity : uint ) -> ~[ T ] {
210
180
unsafe {
211
181
let alloc = capacity * mem:: nonzero_size_of :: < T > ( ) ;
@@ -1503,31 +1473,6 @@ impl<T> OwnedVector<T> for ~[T] {
1503
1473
self . move_iter ( ) . invert ( )
1504
1474
}
1505
1475
1506
- #[ cfg( stage0) ]
1507
- fn reserve ( & mut self , n : uint ) {
1508
- // Only make the (slow) call into the runtime if we have to
1509
- if self . capacity ( ) < n {
1510
- unsafe {
1511
- let td = get_tydesc :: < T > ( ) ;
1512
- if owns_managed :: < T > ( ) {
1513
- let ptr: * mut * mut Box < Vec < ( ) > > = cast:: transmute ( self ) ;
1514
- :: at_vec:: raw:: reserve_raw ( td, ptr, n) ;
1515
- } else {
1516
- let ptr: * mut * mut Vec < ( ) > = cast:: transmute ( self ) ;
1517
- let alloc = n * mem:: nonzero_size_of :: < T > ( ) ;
1518
- let size = alloc + mem:: size_of :: < Vec < ( ) > > ( ) ;
1519
- if alloc / mem:: nonzero_size_of :: < T > ( ) != n || size < alloc {
1520
- fail ! ( "vector size is too large: {}" , n) ;
1521
- }
1522
- * ptr = realloc_raw ( * ptr as * mut c_void , size)
1523
- as * mut Vec < ( ) > ;
1524
- ( * * ptr) . alloc = alloc;
1525
- }
1526
- }
1527
- }
1528
- }
1529
-
1530
- #[ cfg( not( stage0) ) ]
1531
1476
fn reserve ( & mut self , n : uint ) {
1532
1477
// Only make the (slow) call into the runtime if we have to
1533
1478
if self . capacity ( ) < n {
@@ -1561,21 +1506,6 @@ impl<T> OwnedVector<T> for ~[T] {
1561
1506
}
1562
1507
1563
1508
#[ inline]
1564
- #[ cfg( stage0) ]
1565
- fn capacity ( & self ) -> uint {
1566
- unsafe {
1567
- if owns_managed :: < T > ( ) {
1568
- let repr: * * Box < Vec < ( ) > > = cast:: transmute ( self ) ;
1569
- ( * * repr) . data . alloc / mem:: nonzero_size_of :: < T > ( )
1570
- } else {
1571
- let repr: * * Vec < ( ) > = cast:: transmute ( self ) ;
1572
- ( * * repr) . alloc / mem:: nonzero_size_of :: < T > ( )
1573
- }
1574
- }
1575
- }
1576
-
1577
- #[ inline]
1578
- #[ cfg( not( stage0) ) ]
1579
1509
fn capacity ( & self ) -> uint {
1580
1510
unsafe {
1581
1511
let repr: * * Vec < ( ) > = cast:: transmute ( self ) ;
@@ -1594,51 +1524,6 @@ impl<T> OwnedVector<T> for ~[T] {
1594
1524
}
1595
1525
1596
1526
#[ inline]
1597
- #[ cfg( stage0) ]
1598
- fn push ( & mut self , t : T ) {
1599
- unsafe {
1600
- if owns_managed :: < T > ( ) {
1601
- let repr: * * Box < Vec < ( ) > > = cast:: transmute ( & mut * self ) ;
1602
- let fill = ( * * repr) . data . fill ;
1603
- if ( * * repr) . data . alloc <= fill {
1604
- self . reserve_additional ( 1 ) ;
1605
- }
1606
-
1607
- push_fast ( self , t) ;
1608
- } else {
1609
- let repr: * * Vec < ( ) > = cast:: transmute ( & mut * self ) ;
1610
- let fill = ( * * repr) . fill ;
1611
- if ( * * repr) . alloc <= fill {
1612
- self . reserve_additional ( 1 ) ;
1613
- }
1614
-
1615
- push_fast ( self , t) ;
1616
- }
1617
- }
1618
-
1619
- // This doesn't bother to make sure we have space.
1620
- #[ inline] // really pretty please
1621
- unsafe fn push_fast < T > ( this : & mut ~[ T ] , t : T ) {
1622
- if owns_managed :: < T > ( ) {
1623
- let repr: * * mut Box < Vec < u8 > > = cast:: transmute ( this) ;
1624
- let fill = ( * * repr) . data . fill ;
1625
- ( * * repr) . data . fill += mem:: nonzero_size_of :: < T > ( ) ;
1626
- let p = to_unsafe_ptr ( & ( ( * * repr) . data . data ) ) ;
1627
- let p = ptr:: offset ( p, fill as int ) as * mut T ;
1628
- intrinsics:: move_val_init ( & mut ( * p) , t) ;
1629
- } else {
1630
- let repr: * * mut Vec < u8 > = cast:: transmute ( this) ;
1631
- let fill = ( * * repr) . fill ;
1632
- ( * * repr) . fill += mem:: nonzero_size_of :: < T > ( ) ;
1633
- let p = to_unsafe_ptr ( & ( ( * * repr) . data ) ) ;
1634
- let p = ptr:: offset ( p, fill as int ) as * mut T ;
1635
- intrinsics:: move_val_init ( & mut ( * p) , t) ;
1636
- }
1637
- }
1638
- }
1639
-
1640
- #[ inline]
1641
- #[ cfg( not( stage0) ) ]
1642
1527
fn push ( & mut self , t : T ) {
1643
1528
unsafe {
1644
1529
let repr: * * Vec < ( ) > = cast:: transmute ( & mut * self ) ;
@@ -1821,20 +1706,8 @@ impl<T> OwnedVector<T> for ~[T] {
1821
1706
i += 1 u;
1822
1707
}
1823
1708
}
1824
- #[ inline]
1825
- #[ cfg( stage0) ]
1826
- unsafe fn set_len ( & mut self , new_len : uint ) {
1827
- if owns_managed :: < T > ( ) {
1828
- let repr: * * mut Box < Vec < ( ) > > = cast:: transmute ( self ) ;
1829
- ( * * repr) . data . fill = new_len * mem:: nonzero_size_of :: < T > ( ) ;
1830
- } else {
1831
- let repr: * * mut Vec < ( ) > = cast:: transmute ( self ) ;
1832
- ( * * repr) . fill = new_len * mem:: nonzero_size_of :: < T > ( ) ;
1833
- }
1834
- }
1835
1709
1836
1710
#[ inline]
1837
- #[ cfg( not( stage0) ) ]
1838
1711
unsafe fn set_len ( & mut self , new_len : uint ) {
1839
1712
let repr: * * mut Vec < ( ) > = cast:: transmute ( self ) ;
1840
1713
( * * repr) . fill = new_len * mem:: nonzero_size_of :: < T > ( ) ;
@@ -3010,23 +2883,6 @@ impl<T> DoubleEndedIterator<T> for MoveIterator<T> {
3010
2883
}
3011
2884
3012
2885
#[ unsafe_destructor]
3013
- #[ cfg( stage0) ]
3014
- impl < T > Drop for MoveIterator < T > {
3015
- fn drop ( & mut self ) {
3016
- // destroy the remaining elements
3017
- for _x in * self { }
3018
- unsafe {
3019
- if owns_managed :: < T > ( ) {
3020
- local_free ( self . allocation as * u8 as * c_char )
3021
- } else {
3022
- exchange_free ( self . allocation as * u8 as * c_char )
3023
- }
3024
- }
3025
- }
3026
- }
3027
-
3028
- #[ unsafe_destructor]
3029
- #[ cfg( not( stage0) ) ]
3030
2886
impl < T > Drop for MoveIterator < T > {
3031
2887
fn drop ( & mut self ) {
3032
2888
// destroy the remaining elements
0 commit comments