diff options
| author | 许杰友 Jieyou Xu (Joe) <39484203+jieyouxu@users.noreply.github.com> | 2025-08-19 19:50:01 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-19 19:50:01 +0800 |
| commit | bb4af94006e275b3b665c00ced2a08955bd1c085 (patch) | |
| tree | 0086cbd44f9a68c44f23a996d78ef24b2d2782ab | |
| parent | 8365fcb2b840c95eeb0bc377af8bd498fad22245 (diff) | |
| parent | ab19755630ea6eb3c2f2a364300380ab01eff923 (diff) | |
| download | rust-bb4af94006e275b3b665c00ced2a08955bd1c085.tar.gz rust-bb4af94006e275b3b665c00ced2a08955bd1c085.zip | |
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.
| -rw-r--r-- | library/std/src/io/buffered/bufreader/buffer.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/library/std/src/io/buffered/bufreader/buffer.rs b/library/std/src/io/buffered/bufreader/buffer.rs index 574288e579e..9b600cd5575 100644 --- a/library/std/src/io/buffered/bufreader/buffer.rs +++ b/library/std/src/io/buffered/bufreader/buffer.rs @@ -122,7 +122,7 @@ 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.buf.copy_within(self.pos..self.filled, 0); self.filled -= self.pos; self.pos = 0; } |
