feat(tvix/store/digests): use bytes::Bytes instead of Vec<u8>
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 <tvl@lahfa.xyz> Autosubmit: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
This commit is contained in:
parent
72e82ffcb1
commit
a6580748aa
14 changed files with 99 additions and 68 deletions
|
|
@ -142,12 +142,13 @@ impl DirectoryService for GRPCDirectoryService {
|
|||
.spawn(async move { grpc_client.put(tokio_stream::iter(vec![directory])).await });
|
||||
|
||||
match self.tokio_handle.block_on(task)? {
|
||||
Ok(put_directory_resp) => Ok(B3Digest::from_vec(
|
||||
put_directory_resp.into_inner().root_digest,
|
||||
)
|
||||
.map_err(|_| {
|
||||
Error::StorageError("invalid root digest length in response".to_string())
|
||||
})?),
|
||||
Ok(put_directory_resp) => Ok(put_directory_resp
|
||||
.into_inner()
|
||||
.root_digest
|
||||
.try_into()
|
||||
.map_err(|_| {
|
||||
Error::StorageError("invalid root digest length in response".to_string())
|
||||
})?),
|
||||
Err(e) => Err(crate::Error::StorageError(e.to_string())),
|
||||
}
|
||||
}
|
||||
|
|
@ -265,7 +266,7 @@ impl Iterator for StreamIterator {
|
|||
for child_directory in &directory.directories {
|
||||
// We ran validate() above, so we know these digests must be correct.
|
||||
let child_directory_digest =
|
||||
B3Digest::from_vec(child_directory.digest.clone()).unwrap();
|
||||
child_directory.digest.clone().try_into().unwrap();
|
||||
|
||||
self.expected_directory_digests
|
||||
.insert(child_directory_digest);
|
||||
|
|
@ -355,7 +356,7 @@ impl DirectoryPutter for GRPCPutter {
|
|||
.map_err(|e| Error::StorageError(e.to_string()))?
|
||||
.root_digest;
|
||||
|
||||
B3Digest::from_vec(root_digest).map_err(|_| {
|
||||
root_digest.try_into().map_err(|_| {
|
||||
Error::StorageError("invalid root digest length in response".to_string())
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue