Mercurial > public > mercurial-scm > hg
diff rust/hg-core/src/revlog/index.rs @ 46090:9eb07ab3f2d4
rhg: use persistent nodemap when available
? for node ID ? revision number lookups, instead on linear scan in a revlog.
Differential Revision: https://phab.mercurial-scm.org/D9520
author | Simon Sapin <simon-commits@exyr.org> |
---|---|
date | Fri, 04 Dec 2020 17:27:10 +0100 |
parents | 88e741bf2d93 |
children | 43d63979a75e |
line wrap: on
line diff
--- a/rust/hg-core/src/revlog/index.rs Mon Dec 07 18:06:53 2020 +0100 +++ b/rust/hg-core/src/revlog/index.rs Fri Dec 04 17:27:10 2020 +0100 @@ -132,6 +132,16 @@ } } +impl super::RevlogIndex for Index { + fn len(&self) -> usize { + self.len() + } + + fn node(&self, rev: Revision) -> Option<&Node> { + self.get_entry(rev).map(|entry| entry.hash()) + } +} + #[derive(Debug)] pub struct IndexEntry<'a> { bytes: &'a [u8], @@ -190,7 +200,7 @@ /// /// Currently, SHA-1 is used and only the first 20 bytes of this field /// are used. - pub fn hash(&self) -> &Node { + pub fn hash(&self) -> &'a Node { (&self.bytes[32..52]).try_into().unwrap() } }