aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Wilm <joe@jwilm.com>2018-05-19 15:58:49 -0700
committerJoe Wilm <joe@jwilm.com>2018-05-19 15:58:49 -0700
commit182524b8842c81b91c20f30d97880081ec0b9a9a (patch)
tree415ea7218f9bec2e8bfbf0a7355167bcc1b3c751
parent284bed686a9f7375ae2bfc17658d66b5f7c6b025 (diff)
downloadalacritty-182524b8842c81b91c20f30d97880081ec0b9a9a.tar.gz
alacritty-182524b8842c81b91c20f30d97880081ec0b9a9a.zip
Remove checking on remainder op
The length of the underlying storage will *never* be zero.
-rw-r--r--src/grid/storage.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/grid/storage.rs b/src/grid/storage.rs
index eb87c622..ea220159 100644
--- a/src/grid/storage.rs
+++ b/src/grid/storage.rs
@@ -178,6 +178,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()
}