Skip to content

Commit

Permalink
Auto merge of #22669 - dotdash:fast_slice_iter, r=huonw
Browse files Browse the repository at this point in the history
This adds the assume() calls back that got lost when rebasing #21886.
  • Loading branch information
bors committed Feb 28, 2015
2 parents e233987 + e457328 commit 1c93934
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/libcollections/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,10 @@ impl<T> Vec<T> {
#[stable(feature = "rust1", since = "1.0.0")]
pub fn as_mut_slice(&mut self) -> &mut [T] {
unsafe {
let ptr = *self.ptr;
assume(!ptr.is_null());
mem::transmute(RawSlice {
data: *self.ptr,
data: ptr,
len: self.len,
})
}
Expand All @@ -458,6 +460,7 @@ impl<T> Vec<T> {
pub fn into_iter(self) -> IntoIter<T> {
unsafe {
let ptr = *self.ptr;
assume(!ptr.is_null());
let cap = self.cap;
let begin = ptr as *const T;
let end = if mem::size_of::<T>() == 0 {
Expand Down
3 changes: 3 additions & 0 deletions src/libcore/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ use cmp::{Ordering, PartialEq, PartialOrd, Eq, Ord};
use cmp::Ordering::{Less, Equal, Greater};
use cmp;
use default::Default;
use intrinsics::assume;
use iter::*;
use ops::{FnMut, self, Index};
use ops::RangeFull;
Expand Down Expand Up @@ -137,6 +138,7 @@ impl<T> SliceExt for [T] {
fn iter<'a>(&'a self) -> Iter<'a, T> {
unsafe {
let p = self.as_ptr();
assume(!p.is_null());
if mem::size_of::<T>() == 0 {
Iter {ptr: p,
end: (p as usize + self.len()) as *const T,
Expand Down Expand Up @@ -276,6 +278,7 @@ impl<T> SliceExt for [T] {
fn iter_mut<'a>(&'a mut self) -> IterMut<'a, T> {
unsafe {
let p = self.as_mut_ptr();
assume(!p.is_null());
if mem::size_of::<T>() == 0 {
IterMut {ptr: p,
end: (p as usize + self.len()) as *mut T,
Expand Down

0 comments on commit 1c93934

Please sign in to comment.