aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-08-16 05:08:21 +0000
committerBlaž Hrastnik2021-08-20 04:43:54 +0000
commit0300dbdeb378fa5797a23ce8b3f72e2749c3ce50 (patch)
treef807e83d0f8c11521c8d61b0f4533f274843899d
parent54dc2f8107229952928bc68f24946398a84cd56b (diff)
Avoid cloning a request on send
-rw-r--r--helix-dap/src/transport.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/helix-dap/src/transport.rs b/helix-dap/src/transport.rs
index e17dc53d..bca1351c 100644
--- a/helix-dap/src/transport.rs
+++ b/helix-dap/src/transport.rs
@@ -127,11 +127,13 @@ impl Transport {
async fn send_payload_to_server(
&self,
server_stdin: &mut Box<dyn AsyncWrite + Unpin + Send>,
- req: Request,
+ mut req: Request,
) -> Result<()> {
- let json = serde_json::to_string(&Payload::Request(req.clone()))?;
- if let Some(back) = req.back_ch {
- self.pending_requests.lock().await.insert(req.seq, back);
+ let back_ch = req.back_ch.take();
+ let seq = req.seq;
+ 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
}