Shrink some slice iterator MIR
This commit is contained in:
parent
4236da52af
commit
eac6b2910a
1 changed files with 4 additions and 2 deletions
|
@ -103,7 +103,8 @@ macro_rules! iterator {
|
||||||
// so this new pointer is inside `self` and thus guaranteed to be non-null.
|
// so this new pointer is inside `self` and thus guaranteed to be non-null.
|
||||||
unsafe {
|
unsafe {
|
||||||
if_zst!(mut self,
|
if_zst!(mut self,
|
||||||
len => *len = len.unchecked_sub(offset),
|
// Using the intrinsic directly avoids emitting a UbCheck
|
||||||
|
len => *len = crate::intrinsics::unchecked_sub(*len, offset),
|
||||||
_end => self.ptr = self.ptr.add(offset),
|
_end => self.ptr = self.ptr.add(offset),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -119,7 +120,8 @@ macro_rules! iterator {
|
||||||
// SAFETY: By our precondition, `offset` can be at most the
|
// SAFETY: By our precondition, `offset` can be at most the
|
||||||
// current length, so the subtraction can never overflow.
|
// current length, so the subtraction can never overflow.
|
||||||
len => unsafe {
|
len => unsafe {
|
||||||
*len = len.unchecked_sub(offset);
|
// Using the intrinsic directly avoids emitting a UbCheck
|
||||||
|
*len = crate::intrinsics::unchecked_sub(*len, offset);
|
||||||
self.ptr
|
self.ptr
|
||||||
},
|
},
|
||||||
// SAFETY: the caller guarantees that `offset` doesn't exceed `self.len()`,
|
// SAFETY: the caller guarantees that `offset` doesn't exceed `self.len()`,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue