diff options
| author | Daniel Micay <danielmicay@gmail.com> | 2014-05-12 02:51:00 -0400 |
|---|---|---|
| committer | Daniel Micay <danielmicay@gmail.com> | 2014-05-12 02:52:32 -0400 |
| commit | 8b912bc56be35149a405752f134b8b659366a35c (patch) | |
| tree | 2bed14bec41fcbba6737ef3199623b81e679f0ac /src/libstd/slice.rs | |
| parent | 72fc4a5eb72b8ba96dba66400c7eecac93b0b252 (diff) | |
| download | rust-8b912bc56be35149a405752f134b8b659366a35c.tar.gz rust-8b912bc56be35149a405752f134b8b659366a35c.zip | |
register snapshots
Diffstat (limited to 'src/libstd/slice.rs')
| -rw-r--r-- | src/libstd/slice.rs | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/src/libstd/slice.rs b/src/libstd/slice.rs index 3c0d0efa766..66471ee3923 100644 --- a/src/libstd/slice.rs +++ b/src/libstd/slice.rs @@ -291,54 +291,6 @@ pub trait CloneableVector<T> { impl<'a, T: Clone> CloneableVector<T> for &'a [T] { /// Returns a copy of `v`. #[inline] - #[cfg(stage0)] - fn to_owned(&self) -> ~[T] { - use RawVec = core::raw::Vec; - use num::{CheckedAdd, CheckedMul}; - use option::Expect; - - let len = self.len(); - let data_size = len.checked_mul(&mem::size_of::<T>()); - let data_size = data_size.expect("overflow in to_owned()"); - let size = mem::size_of::<RawVec<()>>().checked_add(&data_size); - let size = size.expect("overflow in to_owned()"); - - unsafe { - // this should pass the real required alignment - let ret = exchange_malloc(size) as *mut RawVec<()>; - - (*ret).fill = len * mem::nonzero_size_of::<T>(); - (*ret).alloc = len * mem::nonzero_size_of::<T>(); - - // Be careful with the following loop. We want it to be optimized - // to a memcpy (or something similarly fast) when T is Copy. LLVM - // is easily confused, so any extra operations during the loop can - // prevent this optimization. - let mut i = 0; - let p = &mut (*ret).data as *mut _ as *mut T; - try_finally( - &mut i, (), - |i, ()| while *i < len { - mem::move_val_init( - &mut(*p.offset(*i as int)), - self.unsafe_ref(*i).clone()); - *i += 1; - }, - |i| if *i < len { - // we must be failing, clean up after ourselves - for j in range(0, *i as int) { - ptr::read(&*p.offset(j)); - } - // FIXME: #13994 (should pass align and size here) - deallocate(ret as *mut u8, 0, 8); - }); - mem::transmute(ret) - } - } - - /// Returns a copy of `v`. - #[inline] - #[cfg(not(stage0))] fn to_owned(&self) -> ~[T] { use RawVec = core::raw::Vec; use num::{CheckedAdd, CheckedMul}; |
