File tree Expand file tree Collapse file tree 2 files changed +4
-16
lines changed Expand file tree Collapse file tree 2 files changed +4
-16
lines changed Original file line number Diff line number Diff line change @@ -52,14 +52,8 @@ pure fn capacity<T>(&&v: @[const T]) -> uint {
5252#[ inline( always) ]
5353pure fn build_sized < A > ( size : uint , builder : fn ( push : pure fn( +A ) ) ) -> @[ A ] {
5454 let mut vec = @[ ] ;
55- unsafe {
56- unsafe :: reserve ( vec, size) ;
57- // This is an awful hack to be able to make the push function
58- // pure. Is there a better way?
59- :: unsafe:: reinterpret_cast ::
60- < fn ( push : pure fn( +A ) ) , fn ( push : fn ( +A ) ) >
61- ( builder) ( |+x| unsafe :: push ( vec, x) ) ;
62- }
55+ unsafe { unsafe :: reserve ( vec, size) ; }
56+ builder ( |+x| unsafe { unsafe :: push ( vec, x) } ) ;
6357 return vec;
6458}
6559
Original file line number Diff line number Diff line change @@ -234,14 +234,8 @@ pure fn from_slice<T: copy>(t: &[T]) -> ~[T] {
234234#[ inline( always) ]
235235pure fn build_sized < A > ( size : uint , builder : fn ( push : pure fn( +A ) ) ) -> ~[ A ] {
236236 let mut vec = ~[ ] ;
237- unsafe {
238- reserve ( vec, size) ;
239- // This is an awful hack to be able to make the push function
240- // pure. Is there a better way?
241- :: unsafe:: reinterpret_cast ::
242- < fn ( push : pure fn( +A ) ) , fn ( push : fn ( +A ) ) >
243- ( builder) ( |+x| push ( vec, x) ) ;
244- }
237+ unchecked { reserve( vec, size) ; }
238+ builder ( |+x| unchecked { push( vec, x) } ) ;
245239 return vec;
246240}
247241
You can’t perform that action at this time.
0 commit comments