Revert "Reuse capacity when possible in <BytesMut as Buf>::advance impl" (#726)

This reverts commit baa5053572.
This commit is contained in:
Alice Ryhl
2024-08-01 22:38:17 +02:00
committed by GitHub
parent 03fdde9dcf
commit f488be48d0
-7
View File
@@ -1148,13 +1148,6 @@ impl Buf for BytesMut {
#[inline] #[inline]
fn advance(&mut self, cnt: usize) { fn advance(&mut self, cnt: usize) {
// Advancing by the length is the same as resetting the length to 0,
// except this way we get to reuse the full capacity.
if cnt == self.remaining() {
self.clear();
return;
}
assert!( assert!(
cnt <= self.remaining(), cnt <= self.remaining(),
"cannot advance past `remaining`: {:?} <= {:?}", "cannot advance past `remaining`: {:?} <= {:?}",