Mercurial > public > mercurial-scm > hg-stable
diff rust/hg-core/src/operations/cat.rs @ 46499:645ee7225fab
rust: Make NodePrefix allocation-free and Copy, remove NodePrefixRef
The `*Ref` struct only existed to avoid allocating `Vec`s
when cloning `NodePrefix`, but we can avoid having `Vec`
in the first place by using an inline array instead.
This makes `NodePrefix` 21 bytes (with 1?for the length)
which is smaller than before as `Vec` alone is 24 bytes.
Differential Revision: https://phab.mercurial-scm.org/D9863
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Mon, 25 Jan 2021 11:48:47 +0100 |
parents | 8a4914397d02 |
children | 4b381dbbf8b7 |
line wrap: on
line diff
--- a/rust/hg-core/src/operations/cat.rs Sat Jan 30 18:30:11 2021 +0800 +++ b/rust/hg-core/src/operations/cat.rs Mon Jan 25 11:48:47 2021 +0100 @@ -88,13 +88,13 @@ _ => { let changelog_node = NodePrefix::from_hex(&rev) .map_err(|_| CatRevErrorKind::InvalidRevision)?; - changelog.get_node(changelog_node.borrow())? + changelog.get_node(changelog_node)? } }; let manifest_node = Node::from_hex(&changelog_entry.manifest_node()?) .map_err(|_| CatRevErrorKind::CorruptedRevlog)?; - let manifest_entry = manifest.get_node((&manifest_node).into())?; + let manifest_entry = manifest.get_node(manifest_node.into())?; let mut bytes = vec![]; for (manifest_file, node_bytes) in manifest_entry.files_with_nodes() { @@ -107,7 +107,7 @@ Revlog::open(repo, &index_path, Some(&data_path))?; let file_node = Node::from_hex(node_bytes) .map_err(|_| CatRevErrorKind::CorruptedRevlog)?; - let file_rev = file_log.get_node_rev((&file_node).into())?; + let file_rev = file_log.get_node_rev(file_node.into())?; let data = file_log.get_rev_data(file_rev)?; if data.starts_with(&METADATA_DELIMITER) { let end_delimiter_position = data