1
0
Fork 0
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:
Joe Wilm 2018-05-19 15:58:49 -07:00
parent 284bed686a
commit 182524b884

View file

@ -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()
} }