mirror of
https://github.com/tokio-rs/bytes.git
synced 2026-08-07 00:00:13 +02:00
Reserve capacity in BytesMut::put (#794)
This commit is contained in:
@@ -1210,6 +1210,9 @@ unsafe impl BufMut for BytesMut {
|
||||
Err(bytes) => self.extend_from_slice(&bytes),
|
||||
}
|
||||
} else {
|
||||
// In case the src isn't contiguous, reserve upfront.
|
||||
self.reserve(src.remaining());
|
||||
|
||||
while src.has_remaining() {
|
||||
let s = src.chunk();
|
||||
let l = s.len();
|
||||
|
||||
Reference in New Issue
Block a user