changeset 48573:faa243f345cc

rhg: Store p1, p2, and hash in RevlogEntry This avoids a duplicate index lookup Differential Revision: https://phab.mercurial-scm.org/D11963
author Simon Sapin <simon.sapin@octobus.net>
date Tue, 21 Dec 2021 21:26:14 +0100
parents 0a4ac916673e
children 5026a0d37526
files rust/hg-core/src/revlog/revlog.rs
diffstat 1 files changed, 9 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/rust/hg-core/src/revlog/revlog.rs	Tue Dec 21 21:23:46 2021 +0100
+++ b/rust/hg-core/src/revlog/revlog.rs	Tue Dec 21 21:26:14 2021 +0100
@@ -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)