Skip to content

Commit bb4af94

Browse files
authored
Rollup merge of #145538 - lolbinarycat:std-bufreader-buffer-backshift-less, r=tgross35
bufreader::Buffer::backshift: don't move the uninit bytes previous code was perfectly sound because of MaybeUninit, but it did waste cycles on copying memory that is known to be uninitialized.
2 parents 8365fcb + ab19755 commit bb4af94

File tree

1 file changed

+1
-1
lines changed
  • library/std/src/io/buffered/bufreader

1 file changed

+1
-1
lines changed

library/std/src/io/buffered/bufreader/buffer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl Buffer {
122122

123123
/// Remove bytes that have already been read from the buffer.
124124
pub fn backshift(&mut self) {
125-
self.buf.copy_within(self.pos.., 0);
125+
self.buf.copy_within(self.pos..self.filled, 0);
126126
self.filled -= self.pos;
127127
self.pos = 0;
128128
}

0 commit comments

Comments
 (0)