[Request] [+ ] D11963: rhg: Store p1, p2, and hash in RevlogEntry

SimonSapin phabricator at mercurial-scm.org
Thu Jan 6 18:57:42 UTC 2022


SimonSapin created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This avoids a duplicate index lookup

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

CHANGE DETAILS

diff --git a/rust/hg-core/src/revlog/revlog.rs b/rust/hg-core/src/revlog/revlog.rs
--- a/rust/hg-core/src/revlog/revlog.rs
+++ b/rust/hg-core/src/revlog/revlog.rs
@@ -280,6 +280,9 @@
             } else {
                 Some(index_entry.base_revision_or_base_of_delta_chain())
             },
+            p1: index_entry.p1(),
+            p2: index_entry.p2(),
+            hash: *index_entry.hash(),
         };
         Ok(entry)
     }
@@ -304,6 +307,9 @@
     compressed_len: u32,
     uncompressed_len: i32,
     base_rev_or_base_of_delta_chain: Option<Revision>,
+    p1: Revision,
+    p2: Revision,
+    hash: Node,
 }
 
 impl<'a> RevlogEntry<'a> {
@@ -335,13 +341,6 @@
             entry = self.revlog.get_entry_internal(base_rev)?;
         }
 
-        // TODO do not look twice in the index
-        let index_entry = self
-            .revlog
-            .index
-            .get_entry(self.rev)
-            .ok_or_else(corrupted)?;
-
         let data = if delta_chain.is_empty() {
             entry.data_chunk()?
         } else {
@@ -349,9 +348,9 @@
         };
 
         if self.revlog.check_hash(
-            index_entry.p1(),
-            index_entry.p2(),
-            index_entry.hash().as_bytes(),
+            self.p1,
+            self.p2,
+            self.hash.as_bytes(),
             &data,
         ) {
             Ok(data)



To: SimonSapin, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20220106/f163142c/attachment.html>


More information about the Mercurial-patches mailing list