Rollup merge of #139068 - a1phyr:less_uninit, r=joboet
io: Avoid marking some bytes as uninit These bytes were marked as uninit, which would cause them to be initialized multiple times even though it was not necessary.
This commit is contained in:
commit
ff8f2eff3a
2 changed files with 4 additions and 2 deletions
|
|
@ -123,7 +123,6 @@ impl Buffer {
|
|||
/// Remove bytes that have already been read from the buffer.
|
||||
pub fn backshift(&mut self) {
|
||||
self.buf.copy_within(self.pos.., 0);
|
||||
self.initialized -= self.pos;
|
||||
self.filled -= self.pos;
|
||||
self.pos = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -248,8 +248,11 @@ impl<I: Write + ?Sized> BufferedWriterSpec for BufWriter<I> {
|
|||
Err(e) => return Err(e),
|
||||
}
|
||||
} else {
|
||||
// All the bytes that were already in the buffer are initialized,
|
||||
// treat them as such when the buffer is flushed.
|
||||
init += buf.len();
|
||||
|
||||
self.flush_buf()?;
|
||||
init = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue