Skip to content

Commit b740c55

Browse files
committed
Use a Box<[u8]> in BufReader
Saves a word, and also prevents the impl from accidentally changing the buffer length.
1 parent 51108b6 commit b740c55

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)