rhg: Store p1, p2, and hash in RevlogEntry
authorSimon Sapin <simon.sapin@octobus.net>
Tue, 21 Dec 2021 21:26:14 +0100
changeset 48573 faa243f345cc
parent 48572 0a4ac916673e
child 48574 5026a0d37526
rhg: Store p1, p2, and hash in RevlogEntry This avoids a duplicate index lookup Differential Revision: https://phab.mercurial-scm.org/D11963
rust/hg-core/src/revlog/revlog.rs
--- 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)