Skip to content

Commit

Permalink
Reduce memory allocations by 50%
Browse files Browse the repository at this point in the history
  • Loading branch information
levkk committed Jan 27, 2025
1 parent 2e77ee0 commit 1a46e68
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pgdog/src/net/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ impl Stream {
let code = self.read_u8().await?;
let len = self.read_i32().await?;

let mut bytes = BytesMut::new();
let mut bytes = BytesMut::with_capacity(len as usize + 1);

bytes.put_u8(code);
bytes.put_i32(len);
Expand Down

0 comments on commit 1a46e68

Please # to comment.