mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 08:47:12 +03:00
mononoke: use Bytes for ContentChunk thrift
Summary: Can reduce number of allocations and copies by sharing the underlying thrift buffer Reviewed By: markbt Differential Revision: D27043232 fbshipit-source-id: a6e58c53035cb07f7b205df465a9ba2f7a78d52e
This commit is contained in:
parent
fc7e4d9e33
commit
c5a1fa65a3
@ -143,7 +143,7 @@ union FileContents {
|
||||
}
|
||||
|
||||
union ContentChunk {
|
||||
1: binary Bytes,
|
||||
1: binary_bytes Bytes,
|
||||
}
|
||||
|
||||
// Payload of object which is an alias
|
||||
|
@ -41,11 +41,11 @@ impl ContentChunk {
|
||||
}
|
||||
|
||||
pub(crate) fn into_thrift(self) -> thrift::ContentChunk {
|
||||
thrift::ContentChunk::Bytes(self.0.to_vec())
|
||||
thrift::ContentChunk::Bytes(self.0)
|
||||
}
|
||||
|
||||
pub fn from_encoded_bytes(encoded_bytes: Bytes) -> Result<Self> {
|
||||
let thrift_tc = compact_protocol::deserialize(encoded_bytes.as_ref())
|
||||
let thrift_tc = compact_protocol::deserialize(encoded_bytes)
|
||||
.with_context(|| ErrorKind::BlobDeserializeError("ContentChunk".into()))?;
|
||||
Self::from_thrift(thrift_tc)
|
||||
}
|
||||
@ -76,7 +76,7 @@ impl BlobstoreValue for ContentChunk {
|
||||
}
|
||||
|
||||
fn from_blob(blob: ContentChunkBlob) -> Result<Self> {
|
||||
let thrift_tc = compact_protocol::deserialize(blob.data().as_ref())
|
||||
let thrift_tc = compact_protocol::deserialize(blob.data())
|
||||
.with_context(|| ErrorKind::BlobDeserializeError("ContentChunk".into()))?;
|
||||
Self::from_thrift(thrift_tc)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user