Removed redundant bounds checking at Split's next and next_mut methods

This commit is contained in:
lch361 2023-12-25 01:34:07 +03:00
parent e87ccb8676
commit b15e13760a

View File

@ -458,8 +458,8 @@ fn next(&mut self) -> Option<&'a [T]> {
match self.v.iter().position(|x| (self.pred)(x)) {
None => self.finish(),
Some(idx) => {
let ret = Some(&self.v[..idx]);
self.v = &self.v[idx + 1..];
let ret = Some(unsafe { self.v.get_unchecked(..idx) });
self.v = unsafe { self.v.get_unchecked(idx + 1..) };
ret
}
}
@ -491,8 +491,8 @@ fn next_back(&mut self) -> Option<&'a [T]> {
match self.v.iter().rposition(|x| (self.pred)(x)) {
None => self.finish(),
Some(idx) => {
let ret = Some(&self.v[idx + 1..]);
self.v = &self.v[..idx];
let ret = Some(unsafe { self.v.get_unchecked(idx + 1..) });
self.v = unsafe { self.v.get_unchecked(..idx) };
ret
}
}