rust-node: avoid meaningless read at the end of odd prefix
authorGeorges Racinet <georges.racinet@octobus.net>
Mon, 27 Jan 2020 20:28:47 +0100
changeset 44187 be52b7372ec2
parent 44186 796d05f3fa84
child 44188 1f9e6fbdd3e6
rust-node: avoid meaningless read at the end of odd prefix This should be heavily factored out by the CPU branch predictor anyway. Differential Revision: https://phab.mercurial-scm.org/D8019
rust/hg-core/src/revlog/node.rs
--- a/rust/hg-core/src/revlog/node.rs	Fri Dec 27 16:06:54 2019 +0100
+++ b/rust/hg-core/src/revlog/node.rs	Mon Jan 27 20:28:47 2020 +0100
@@ -223,6 +223,7 @@
     /// This is also the `i`th hexadecimal digit in numeric form,
     /// also called a [nybble](https://en.wikipedia.org/wiki/Nibble).
     pub fn get_nybble(&self, i: usize) -> u8 {
+        assert!(i < self.len());
         get_nybble(self.buf, i)
     }
 }