diff options
| author | Huon Wilson <dbau.pp+github@gmail.com> | 2013-12-17 08:33:50 +1100 |
|---|---|---|
| committer | Huon Wilson <dbau.pp+github@gmail.com> | 2013-12-17 08:36:04 +1100 |
| commit | dd355700cf4f1fa1744cdeb165b68898fa30a9d1 (patch) | |
| tree | 10bcba94eccbaaac8a1e58712955d3218d6227f6 /src | |
| parent | 8a5a5922c61cecd5f305a0cd54671dbf2f2a6519 (diff) | |
| download | rust-dd355700cf4f1fa1744cdeb165b68898fa30a9d1.tar.gz rust-dd355700cf4f1fa1744cdeb165b68898fa30a9d1.zip | |
std::vec: make init_elem nicer by doing fewer moves.
Diffstat (limited to 'src')
| -rw-r--r-- | src/libstd/vec.rs | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs index 2a0f575cdde..8722109736c 100644 --- a/src/libstd/vec.rs +++ b/src/libstd/vec.rs @@ -2196,11 +2196,7 @@ impl<'a,T> MutableVector<'a, T> for &'a mut [T] { #[inline] unsafe fn init_elem(self, i: uint, val: T) { - let mut alloc = Some(val); - self.as_mut_buf(|p, _len| { - intrinsics::move_val_init(&mut(*ptr::mut_offset(p, i as int)), - alloc.take_unwrap()); - }) + intrinsics::move_val_init(&mut (*self.as_mut_ptr().offset(i as int)), val); } #[inline] |
