sphinx-key: allocate once when receiving message chunks

This commit is contained in:
irriden
2023-07-26 16:52:18 +00:00
parent 7e290da6a6
commit c86bafddd1

View File

@@ -88,18 +88,19 @@ pub fn make_client(
}
Details::InitialChunk(chunk_info) => {
if let Some(topic) = msg.topic() {
inflight = Vec::with_capacity(chunk_info.total_data_size);
inflight_topic = topic.to_string();
inflight.extend(msg.data().iter());
inflight.extend_from_slice(msg.data());
None
} else {
None
}
}
Details::SubsequentChunk(chunk_data) => {
inflight.extend(msg.data().iter());
inflight.extend_from_slice(msg.data());
if inflight.len() == chunk_data.total_data_size {
let ret = Some((inflight_topic, inflight));
inflight_topic = "".to_string();
inflight_topic = String::new();
inflight = Vec::new();
ret
} else {