D8019: rust-node: avoid meaningless read at the end of odd prefix

gracinet (Georges Racinet) phabricator at mercurial-scm.org
Mon Jan 27 19:35:07 UTC 2020


gracinet created this revision.
Herald added subscribers: mercurial-devel, kevincox.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This should be heavily factored out by the CPU branch predictor
  anyway.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D8019

AFFECTED FILES
  rust/hg-core/src/revlog/node.rs

CHANGE DETAILS

diff --git a/rust/hg-core/src/revlog/node.rs b/rust/hg-core/src/revlog/node.rs
--- a/rust/hg-core/src/revlog/node.rs
+++ b/rust/hg-core/src/revlog/node.rs
@@ -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)
     }
 }



To: gracinet, #hg-reviewers
Cc: kevincox, mercurial-devel


More information about the Mercurial-devel mailing list