mirror of
https://github.com/tokio-rs/axum.git
synced 2024-12-30 16:19:16 +01: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:
parent
3bcc8fb07d
commit
7e7a2f2058
1 changed files with 3 additions and 1 deletions
|
@ -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(()) => (
|
||||
[(
|
||||
|
|
Loading…
Reference in a new issue