From a6580748aabe7fcbea735396ac700661b6c53e87 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Thu, 20 Jul 2023 13:37:29 +0300 Subject: feat(tvix/store/digests): use bytes::Bytes instead of Vec This will save us some copies, because a clone will simply create an additional pointer to the same data. Change-Id: I017a5d6b4c85a861b5541ebad2858ad4fbf8e8fa Reviewed-on: https://cl.tvl.fyi/c/depot/+/8978 Reviewed-by: raitobezarius Autosubmit: flokli Tested-by: BuildkiteCI --- tvix/store/src/proto/mod.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'tvix/store/src/proto/mod.rs') diff --git a/tvix/store/src/proto/mod.rs b/tvix/store/src/proto/mod.rs index 7e81efc51782..126a8b0edce3 100644 --- a/tvix/store/src/proto/mod.rs +++ b/tvix/store/src/proto/mod.rs @@ -247,12 +247,11 @@ impl Directory { pub fn digest(&self) -> B3Digest { let mut hasher = blake3::Hasher::new(); - let vec = hasher + hasher .update(&self.encode_to_vec()) .finalize() .as_bytes() - .to_vec(); - B3Digest::from_vec(vec).unwrap() + .into() } /// validate checks the directory for invalid data, such as: -- cgit 1.4.1