Use a Box<[u8]> in BufReader
Saves a word, and also prevents the impl from accidentally changing the buffer length.
This commit is contained in:
parent
51108b64ca
commit
b740c557e2
@ -47,7 +47,7 @@
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct BufReader<R> {
|
||||
inner: R,
|
||||
buf: Vec<u8>,
|
||||
buf: Box<[u8]>,
|
||||
pos: usize,
|
||||
cap: usize,
|
||||
}
|
||||
@ -92,7 +92,7 @@ pub fn new(inner: R) -> BufReader<R> {
|
||||
pub fn with_capacity(cap: usize, inner: R) -> BufReader<R> {
|
||||
BufReader {
|
||||
inner: inner,
|
||||
buf: vec![0; cap],
|
||||
buf: vec![0; cap].into_boxed_slice(),
|
||||
pos: 0,
|
||||
cap: 0,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user