mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-24 00:00:16 +02:00
Create BytesMut for Json with initial capacity (#1196)
* Create BytesMut for Json with initial capacity * Add a comment explaining BytesMut initial capacity * Update link to serde_json::to_vec function to docs.rs
This commit is contained in:
+3
-1
@@ -186,7 +186,9 @@ where
|
||||
T: Serialize,
|
||||
{
|
||||
fn into_response(self) -> Response {
|
||||
let mut buf = BytesMut::new().writer();
|
||||
// Use a small initial capacity of 128 bytes like serde_json::to_vec
|
||||
// https://docs.rs/serde_json/1.0.82/src/serde_json/ser.rs.html#2189
|
||||
let mut buf = BytesMut::with_capacity(128).writer();
|
||||
match serde_json::to_writer(&mut buf, &self.0) {
|
||||
Ok(()) => (
|
||||
[(
|
||||
|
||||
Reference in New Issue
Block a user