mirror of
https://github.com/alacritty/alacritty.git
synced 2024-11-18 13:55:23 -05:00
Remove checking on remainder op
The length of the underlying storage will *never* be zero. This removes generated code that branches on the possibility that len is zero.
This commit is contained in:
parent
fc2ef0991e
commit
37b8fd8cf5
1 changed files with 8 additions and 0 deletions
|
@ -174,6 +174,14 @@ impl<T> Storage<T> {
|
|||
|
||||
/// Compute actual index in underlying storage given the requested index.
|
||||
fn compute_index(&self, requested: usize) -> usize {
|
||||
use ::std::hint::unreachable_unchecked;
|
||||
|
||||
// This prevents an extra branch being inserted which checks for the
|
||||
// divisor to be zero thus making a % b generate equivalent code as in C
|
||||
if self.inner.len() == 0 {
|
||||
unsafe { unreachable_unchecked(); }
|
||||
}
|
||||
|
||||
(requested + self.zero) % self.inner.len()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue