Mercurial > hg
changeset 52299:4d0c0c255425
rust-revlog: rename `length` to `data_compressed_length`
This is more explicit and will not be confused with `len`.
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Mon, 04 Nov 2024 10:36:45 +0100 |
parents | 645d247d4c75 |
children | e2319309bed4 |
files | rust/hg-core/src/revlog/inner_revlog.rs |
diffstat | 1 files changed, 7 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/rust/hg-core/src/revlog/inner_revlog.rs Tue Oct 29 12:03:55 2024 +0100 +++ b/rust/hg-core/src/revlog/inner_revlog.rs Mon Nov 04 10:36:45 2024 +0100 @@ -233,10 +233,8 @@ } /// The length of the data chunk for this revision - /// TODO rename this method and others to more explicit names than the - /// existing ones that were copied over from Python #[inline(always)] - pub fn length(&self, rev: Revision) -> usize { + pub fn data_compressed_length(&self, rev: Revision) -> usize { self.index .get_entry(rev) .unwrap_or_else(|| self.index.make_null_entry()) @@ -246,7 +244,7 @@ /// The end of the data chunk for this revision #[inline(always)] pub fn end(&self, rev: Revision) -> usize { - self.start(rev) + self.length(rev) + self.start(rev) + self.data_compressed_length(rev) } /// Return the delta parent of the given revision @@ -384,7 +382,8 @@ .index .get_entry(end_rev) .expect("null revision segment"); - let end = self.index.start(end_rev, &end_entry) + self.length(end_rev); + let end = self.index.start(end_rev, &end_entry) + + self.data_compressed_length(end_rev); let length = end - start; @@ -553,7 +552,7 @@ // Skip trailing revisions with empty diff let last_rev_idx = revs_chunk .iter() - .rposition(|r| self.length(*r) != 0) + .rposition(|r| self.data_compressed_length(*r) != 0) .unwrap_or(revs_chunk.len() - 1); let last_rev = revs_chunk[last_rev_idx]; @@ -565,7 +564,7 @@ for rev in revs_chunk { let chunk_start = self.start(*rev); - let chunk_length = self.length(*rev); + let chunk_length = self.data_compressed_length(*rev); // TODO revlogv2 should check the compression mode let bytes = &data[chunk_start - offset..][..chunk_length]; let chunk = if !bytes.is_empty() && bytes[0] == ZSTD_BYTE { @@ -752,7 +751,7 @@ // Trim empty revs at the end, except the very first rev of a chain while end_rev_idx > 1 && end_rev_idx > start_rev_idx - && self.length(revs[end_rev_idx - 1]) == 0 + && self.data_compressed_length(revs[end_rev_idx - 1]) == 0 { end_rev_idx -= 1 }