Skip to content

Commit 00ee90f

Browse files
committed
Auto merge of #31070 - sfackler:bufreader-box-slice, r=alexcrichton
Saves a word, and also prevents the impl from accidentally changing the buffer length. r? @alexcrichton
2 parents 62c8256 + b740c55 commit 00ee90f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/libstd/io/buffered.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ use memchr;
4747
#[stable(feature = "rust1", since = "1.0.0")]
4848
pub struct BufReader<R> {
4949
inner: R,
50-
buf: Vec<u8>,
50+
buf: Box<[u8]>,
5151
pos: usize,
5252
cap: usize,
5353
}
@@ -92,7 +92,7 @@ impl<R: Read> BufReader<R> {
9292
pub fn with_capacity(cap: usize, inner: R) -> BufReader<R> {
9393
BufReader {
9494
inner: inner,
95-
buf: vec![0; cap],
95+
buf: vec![0; cap].into_boxed_slice(),
9696
pos: 0,
9797
cap: 0,
9898
}

0 commit comments

Comments
 (0)