Skip to content

Commit 9189539

Browse files
committed
Use BufReader internally in StreamReader to avoid performance regression on existing callers
1 parent 5dfb93d commit 9189539

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/network/stream_reader.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323
//!
2424
2525
use core::fmt;
26-
use io::Read;
26+
use io::{Read, BufReader};
2727

2828
use consensus::{encode, Decodable};
2929

3030
/// Struct used to configure stream reader function
3131
pub struct StreamReader<R: Read> {
3232
/// Stream to read from
33-
pub stream: R,
33+
pub stream: BufReader<R>,
3434
}
3535

3636
impl<R: Read> fmt::Debug for StreamReader<R> {
@@ -44,7 +44,7 @@ impl<R: Read> StreamReader<R> {
4444
#[deprecated(since="0.28.0", note="wrap you stream into a buffered reader if necessary and use consensus_encode directly")]
4545
pub fn new(stream: R, _buffer_size: Option<usize>) -> StreamReader<R> {
4646
StreamReader {
47-
stream,
47+
stream: BufReader::new(stream),
4848
}
4949
}
5050

0 commit comments

Comments
 (0)