Removed redundant bounds checking at Split's next and next_mut methods
This commit is contained in:
parent
e87ccb8676
commit
b15e13760a
@ -458,8 +458,8 @@ fn next(&mut self) -> Option<&'a [T]> {
|
|||||||
match self.v.iter().position(|x| (self.pred)(x)) {
|
match self.v.iter().position(|x| (self.pred)(x)) {
|
||||||
None => self.finish(),
|
None => self.finish(),
|
||||||
Some(idx) => {
|
Some(idx) => {
|
||||||
let ret = Some(&self.v[..idx]);
|
let ret = Some(unsafe { self.v.get_unchecked(..idx) });
|
||||||
self.v = &self.v[idx + 1..];
|
self.v = unsafe { self.v.get_unchecked(idx + 1..) };
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -491,8 +491,8 @@ fn next_back(&mut self) -> Option<&'a [T]> {
|
|||||||
match self.v.iter().rposition(|x| (self.pred)(x)) {
|
match self.v.iter().rposition(|x| (self.pred)(x)) {
|
||||||
None => self.finish(),
|
None => self.finish(),
|
||||||
Some(idx) => {
|
Some(idx) => {
|
||||||
let ret = Some(&self.v[idx + 1..]);
|
let ret = Some(unsafe { self.v.get_unchecked(idx + 1..) });
|
||||||
self.v = &self.v[..idx];
|
self.v = unsafe { self.v.get_unchecked(..idx) };
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user