Skip to content

Commit c8a5311

Browse files
Merge pull request #84 from QueryaHub/issue-74-form-no-body-clone
perf(form): eliminate multipart full-body clone
2 parents 23d3d70 + 72dcc5b commit c8a5311

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/dispatch.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ pub async fn run_rsgi(
325325
pyo3_async_runtimes::tokio::into_future(aw)
326326
})?;
327327
let body_obj: PyObject = read_fut.await?;
328-
let body_bytes: Vec<u8> = Python::with_gil(|py| -> PyResult<Vec<u8>> {
328+
let mut body_bytes: Vec<u8> = Python::with_gil(|py| -> PyResult<Vec<u8>> {
329329
let b = body_obj.bind(py);
330330
if let Ok(x) = b.extract::<Vec<u8>>() {
331331
return Ok(x);
@@ -521,7 +521,8 @@ pub async fn run_rsgi(
521521
.await
522522
}
523523
};
524-
let parsed = match form::parse_multipart(body_bytes.clone(), &boundary).await {
524+
let multipart_body = std::mem::take(&mut body_bytes);
525+
let parsed = match form::parse_multipart(multipart_body, &boundary).await {
525526
Ok(p) => p,
526527
Err(e) => {
527528
return response::send_text(

0 commit comments

Comments
 (0)