Skip to content

Commit 3069b60

Browse files
committed
CompactEncoding Vec<u8> -> Box<[u8]>
1 parent 819b943 commit 3069b60

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/crypto/hash.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,9 @@ impl Hash {
147147
};
148148

149149
let len = node1.length + node2.length;
150-
let size: Vec<u8> = (|| Ok::<_, EncodingError>(to_encoded_bytes!(len.as_fixed_width())))()
151-
.expect("Encoding u64 should not fail");
150+
let size: Box<[u8]> =
151+
(|| Ok::<_, EncodingError>(to_encoded_bytes!(len.as_fixed_width())))()
152+
.expect("Encoding u64 should not fail");
152153

153154
let mut hasher = Blake2b256::new();
154155
hasher.update(PARENT_TYPE);

src/tree/merkle_tree.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,10 @@ impl MerkleTree {
662662
for (_, node) in self.unflushed.drain() {
663663
let buffer = (|| {
664664
let hash = as_array::<32>(&node.hash)?;
665-
Ok::<Vec<u8>, EncodingError>(to_encoded_bytes!(node.length.as_fixed_width(), hash))
665+
Ok::<Box<[u8]>, EncodingError>(to_encoded_bytes!(
666+
node.length.as_fixed_width(),
667+
hash
668+
))
666669
})()
667670
.expect("Encoding u64 should not fail");
668671
infos_to_flush.push(StoreInfo::new_content(

0 commit comments

Comments
 (0)