Skip to content

Commit eaa81dd

Browse files
authored
chore: Avoid duplicate box on constructing BoxBody (#2009)
1 parent d61a55f commit eaa81dd

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

tonic/src/body.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,14 @@ where
1111
B: http_body::Body<Data = bytes::Bytes> + Send + 'static,
1212
B::Error: Into<crate::BoxError>,
1313
{
14-
body.map_err(crate::Status::map_error).boxed_unsync()
14+
let mut body = Some(body);
15+
if let Some(body) = <dyn std::any::Any>::downcast_mut::<Option<BoxBody>>(&mut body) {
16+
body.take().unwrap()
17+
} else {
18+
body.unwrap()
19+
.map_err(crate::Status::map_error)
20+
.boxed_unsync()
21+
}
1522
}
1623

1724
/// Create an empty `BoxBody`

0 commit comments

Comments
 (0)