From patchwork Thu Jan 6 18:57:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D11963: rhg: Store p1, p2, and hash in RevlogEntry From: phabricator X-Patchwork-Id: 50290 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Thu, 6 Jan 2022 18:57:42 +0000 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 To: SimonSapin, #hg-reviewers Cc: mercurial-patches, mercurial-devel 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, + 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)