We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ce09d7d commit baa5053Copy full SHA for baa5053
src/bytes_mut.rs
@@ -1066,6 +1066,14 @@ impl Buf for BytesMut {
1066
1067
#[inline]
1068
fn advance(&mut self, cnt: usize) {
1069
+ // Advancing by the length is the same as resetting the length to 0,
1070
+ // except this way we get to reuse the full capacity.
1071
+ if cnt == self.remaining() {
1072
+ // SAFETY: Zero is not greater than the capacity.
1073
+ unsafe { self.set_len(0) };
1074
+ return;
1075
+ }
1076
+
1077
assert!(
1078
cnt <= self.remaining(),
1079
"cannot advance past `remaining`: {:?} <= {:?}",
0 commit comments