Optimize pointer::as_aligned_to
This commit is contained in:
parent
1f5d8d49eb
commit
c195f7c0a4
2 changed files with 2 additions and 8 deletions
|
@ -1614,11 +1614,8 @@ impl<T: ?Sized> *mut T {
|
|||
panic!("is_aligned_to: align is not a power-of-two");
|
||||
}
|
||||
|
||||
// SAFETY: `is_power_of_two()` will return `false` for zero.
|
||||
unsafe { core::intrinsics::assume(align != 0) };
|
||||
|
||||
// Cast is needed for `T: !Sized`
|
||||
self.cast::<u8>().addr() % align == 0
|
||||
self.cast::<u8>().addr() & align - 1 == 0
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue