# HG changeset patch # User Simon Sapin # Date 1640118374 -3600 # Node ID faa243f345cc19a432eb0890ab738d7775532234 # Parent 0a4ac916673ea5f02a0da49fa04fe56d2da3e429 rhg: Store p1, p2, and hash in RevlogEntry This avoids a duplicate index lookup Differential Revision: https://phab.mercurial-scm.org/D11963 diff -r 0a4ac916673e -r faa243f345cc 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, + 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)