mirror of
https://github.com/alacritty/alacritty.git
synced 2024-11-25 14:05:41 -05:00
Remove checking on remainder op
The length of the underlying storage will *never* be zero.
This commit is contained in:
parent
284bed686a
commit
182524b884
1 changed files with 8 additions and 0 deletions
|
@ -178,6 +178,14 @@ impl<T> Storage<T> {
|
||||||
|
|
||||||
/// Compute actual index in underlying storage given the requested index.
|
/// Compute actual index in underlying storage given the requested index.
|
||||||
fn compute_index(&self, requested: usize) -> usize {
|
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()
|
(requested + self.zero) % self.inner.len()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue