diff options
| author | Huon Wilson <dbau.pp+github@gmail.com> | 2013-12-15 22:44:51 +1100 |
|---|---|---|
| committer | Huon Wilson <dbau.pp+github@gmail.com> | 2013-12-15 23:05:00 +1100 |
| commit | 4f62c969f618463914b148d53bef1d0faeb2782f (patch) | |
| tree | 3a6a4bfd063c9b9caf606aff7ad0a409399897d1 /src/libstd | |
| parent | 0393c402a6f523993bb47c579d7382bec507bde7 (diff) | |
| download | rust-4f62c969f618463914b148d53bef1d0faeb2782f.tar.gz rust-4f62c969f618463914b148d53bef1d0faeb2782f.zip | |
std::vec: move pointless `raw::get` and `unsafe_get` functions.
This can easily be written as `(*v.unsafe_ref(i)).clone()`, or just `*v.unsafe_ref(i)` for primitive types like `i32` (the common case).
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/rand/isaac.rs | 8 | ||||
| -rw-r--r-- | src/libstd/vec.rs | 16 |
2 files changed, 4 insertions, 20 deletions
diff --git a/src/libstd/rand/isaac.rs b/src/libstd/rand/isaac.rs index 3dcf97212f5..5ba6994b78d 100644 --- a/src/libstd/rand/isaac.rs +++ b/src/libstd/rand/isaac.rs @@ -341,7 +341,7 @@ impl Isaac64Rng { static MP_VEC: [(uint, uint), .. 2] = [(0,MIDPOINT), (MIDPOINT, 0)]; macro_rules! ind ( ($x:expr) => { - self.mem.unsafe_get(($x as uint >> 3) & (RAND_SIZE_64 - 1)) + *self.mem.unsafe_ref(($x as uint >> 3) & (RAND_SIZE_64 - 1)) } ); macro_rules! rngstep( @@ -355,8 +355,8 @@ impl Isaac64Rng { let mix = if $j == 0 {!mix} else {mix}; unsafe { - let x = self.mem.unsafe_get(base + mr_offset); - a = mix + self.mem.unsafe_get(base + m2_offset); + let x = *self.mem.unsafe_ref(base + mr_offset); + a = mix + *self.mem.unsafe_ref(base + m2_offset); let y = ind!(x) + a + b; self.mem.unsafe_set(base + mr_offset, y); @@ -395,7 +395,7 @@ impl Rng for Isaac64Rng { self.isaac64(); } self.cnt -= 1; - unsafe { self.rsl.unsafe_get(self.cnt) } + unsafe { *self.rsl.unsafe_ref(self.cnt) } } } diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs index c14068a7c88..fc051a7e2b5 100644 --- a/src/libstd/vec.rs +++ b/src/libstd/vec.rs @@ -1270,8 +1270,6 @@ pub trait ImmutableCopyableVector<T> { * those that do not. */ fn partitioned(&self, f: |&T| -> bool) -> (~[T], ~[T]); - /// Returns the element at the given index, without doing bounds checking. - unsafe fn unsafe_get(&self, elem: uint) -> T; /// Create an iterator that yields every possible permutation of the /// vector in succession. @@ -1295,11 +1293,6 @@ impl<'a,T:Clone> ImmutableCopyableVector<T> for &'a [T] { (lefts, rights) } - #[inline] - unsafe fn unsafe_get(&self, index: uint) -> T { - (*self.unsafe_ref(index)).clone() - } - fn permutations(self) -> Permutations<T> { Permutations{ swaps: ElementSwaps::new(self.len()), @@ -2192,7 +2185,6 @@ pub unsafe fn from_buf<T>(ptr: *T, elts: uint) -> ~[T] { /// Unsafe operations pub mod raw { use cast; - use clone::Clone; use option::Some; use ptr; use mem; @@ -2270,14 +2262,6 @@ pub mod raw { } /** - * Unchecked vector indexing. - */ - #[inline] - pub unsafe fn get<T:Clone>(v: &[T], i: uint) -> T { - v.as_imm_buf(|p, _len| (*ptr::offset(p, i as int)).clone()) - } - - /** * Unchecked vector index assignment. Does not drop the * old value and hence is only suitable when the vector * is newly allocated. |
