Reserve capacity in BytesMut::put (#794)

This commit is contained in:
Stepan Koltsov
2025-08-19 12:50:38 +02:00
committed by GitHub
parent ef7f25736c
commit 016fdbdc7a
+3
View File
@@ -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();