diff options
| author | Brian Anderson <banderson@mozilla.com> | 2014-08-06 20:08:16 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2014-08-13 11:30:14 -0700 |
| commit | 033f28d4364e0bd0ff7031b67e6bd0356fe00bfd (patch) | |
| tree | b1f101da8d54893d32a4766157fadceeb80d890f | |
| parent | fbc93082ec92c3534c4b27fef35d78d97bd77fd2 (diff) | |
| download | rust-033f28d4364e0bd0ff7031b67e6bd0356fe00bfd.tar.gz rust-033f28d4364e0bd0ff7031b67e6bd0356fe00bfd.zip | |
core: Rename ImmutableSlice::unsafe_ref to unsafe_get
Deprecate the previous.
| -rw-r--r-- | src/libcollections/string.rs | 2 | ||||
| -rw-r--r-- | src/libcollections/trie.rs | 2 | ||||
| -rw-r--r-- | src/libcollections/vec.rs | 6 | ||||
| -rw-r--r-- | src/libcore/slice.rs | 12 | ||||
| -rw-r--r-- | src/librand/isaac.rs | 12 |
5 files changed, 23 insertions, 11 deletions
diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index d8cc80fdf41..3b9e2ac72dc 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -141,7 +141,7 @@ impl String { let mut i = 0; let total = v.len(); fn unsafe_get(xs: &[u8], i: uint) -> u8 { - unsafe { *xs.unsafe_ref(i) } + unsafe { *xs.unsafe_get(i) } } fn safe_get(xs: &[u8], i: uint, total: uint) -> u8 { if i >= total { diff --git a/src/libcollections/trie.rs b/src/libcollections/trie.rs index c3dcebfc815..dcfe2568074 100644 --- a/src/libcollections/trie.rs +++ b/src/libcollections/trie.rs @@ -926,7 +926,7 @@ macro_rules! iterator_impl { // such thing as invalid pointers and memory unsafety. The // reason is performance, without doing this we can get the // bench_iter_large microbenchmark down to about 30000 ns/iter - // (using .unsafe_ref to index self.stack directly, 38000 + // (using .unsafe_get to index self.stack directly, 38000 // ns/iter with [] checked indexing), but this smashes that down // to 13500 ns/iter. // diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index 78809e32fe9..fd069f54727 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -348,7 +348,7 @@ impl<T: Clone> Vec<T> { unsafe { ptr::write( self.as_mut_slice().unsafe_mut_ref(len), - other.unsafe_ref(i).clone()); + other.unsafe_get(i).clone()); self.set_len(len + 1); } } @@ -703,7 +703,7 @@ impl<T> Vec<T> { // decrement len before the read(), so a failure on Drop doesn't // re-drop the just-failed value. self.len -= 1; - ptr::read(self.as_slice().unsafe_ref(self.len)); + ptr::read(self.as_slice().unsafe_get(self.len)); } } } @@ -1605,7 +1605,7 @@ impl<T> MutableSeq<T> for Vec<T> { } else { unsafe { self.len -= 1; - Some(ptr::read(self.as_slice().unsafe_ref(self.len()))) + Some(ptr::read(self.as_slice().unsafe_get(self.len()))) } } } diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index 3a619b45e53..8d574376719 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -173,8 +173,14 @@ pub trait ImmutableSlice<'a, T> { /// Returns a pointer to the element at the given index, without doing /// bounds checking. + #[deprecated = "renamed to `unsafe_get`"] unsafe fn unsafe_ref(self, index: uint) -> &'a T; + /// Returns a pointer to the element at the given index, without doing + /// bounds checking. + #[unstable] + unsafe fn unsafe_get(self, index: uint) -> &'a T; + /** * Returns an unsafe pointer to the vector's buffer * @@ -351,11 +357,17 @@ impl<'a,T> ImmutableSlice<'a, T> for &'a [T] { } #[inline] + #[deprecated = "renamed to `unsafe_get`"] unsafe fn unsafe_ref(self, index: uint) -> &'a T { transmute(self.repr().data.offset(index as int)) } #[inline] + unsafe fn unsafe_get(self, index: uint) -> &'a T { + transmute(self.repr().data.offset(index as int)) + } + + #[inline] fn as_ptr(&self) -> *const T { self.repr().data } diff --git a/src/librand/isaac.rs b/src/librand/isaac.rs index 134e7af5070..2fbfa6d6e85 100644 --- a/src/librand/isaac.rs +++ b/src/librand/isaac.rs @@ -348,7 +348,7 @@ impl Isaac64Rng { static MP_VEC: [(uint, uint), .. 2] = [(0,MIDPOINT), (MIDPOINT, 0)]; macro_rules! ind ( ($x:expr) => { - *self.mem.unsafe_ref(($x as uint >> 3) & (RAND_SIZE_64 - 1)) + *self.mem.unsafe_get(($x as uint >> 3) & (RAND_SIZE_64 - 1)) } ); @@ -362,8 +362,8 @@ impl Isaac64Rng { let mix = if $j == 0 {!mix} else {mix}; unsafe { - let x = *self.mem.unsafe_ref(base + mr_offset); - a = mix + *self.mem.unsafe_ref(base + m2_offset); + let x = *self.mem.unsafe_get(base + mr_offset); + a = mix + *self.mem.unsafe_get(base + m2_offset); let y = ind!(x) + a + b; self.mem.unsafe_set(base + mr_offset, y); @@ -379,8 +379,8 @@ impl Isaac64Rng { let mix = if $j == 0 {!mix} else {mix}; unsafe { - let x = *self.mem.unsafe_ref(base + mr_offset); - a = mix + *self.mem.unsafe_ref(base + m2_offset); + let x = *self.mem.unsafe_get(base + mr_offset); + a = mix + *self.mem.unsafe_get(base + m2_offset); let y = ind!(x) + a + b; self.mem.unsafe_set(base + mr_offset, y); @@ -416,7 +416,7 @@ impl Rng for Isaac64Rng { self.isaac64(); } self.cnt -= 1; - unsafe { *self.rsl.unsafe_ref(self.cnt) } + unsafe { *self.rsl.unsafe_get(self.cnt) } } } |
