Avoid cloning a request on send

pull/574/head
Blaž Hrastnik 3 years ago
parent 54dc2f8107
commit 0300dbdeb3

@ -127,11 +127,13 @@ impl Transport {
async fn send_payload_to_server( async fn send_payload_to_server(
&self, &self,
server_stdin: &mut Box<dyn AsyncWrite + Unpin + Send>, server_stdin: &mut Box<dyn AsyncWrite + Unpin + Send>,
req: Request, mut req: Request,
) -> Result<()> { ) -> Result<()> {
let json = serde_json::to_string(&Payload::Request(req.clone()))?; let back_ch = req.back_ch.take();
if let Some(back) = req.back_ch { let seq = req.seq;
self.pending_requests.lock().await.insert(req.seq, back); let json = serde_json::to_string(&Payload::Request(req))?;
if let Some(back) = back_ch {
self.pending_requests.lock().await.insert(seq, back);
} }
self.send_string_to_server(server_stdin, json).await self.send_string_to_server(server_stdin, json).await
} }

Loading…
Cancel
Save