Use BufReader internally in StreamReader to avoid performance regression on existing callers

This commit is contained in:
Riccardo Casatta 2022-01-04 10:31:45 +01:00
parent 5dfb93df71
commit 9189539715
No known key found for this signature in database
GPG Key ID: FD986A969E450397
1 changed files with 3 additions and 3 deletions

View File

@ -23,14 +23,14 @@
//! //!
use core::fmt; use core::fmt;
use io::Read; use io::{Read, BufReader};
use consensus::{encode, Decodable}; use consensus::{encode, Decodable};
/// Struct used to configure stream reader function /// Struct used to configure stream reader function
pub struct StreamReader<R: Read> { pub struct StreamReader<R: Read> {
/// Stream to read from /// Stream to read from
pub stream: R, pub stream: BufReader<R>,
} }
impl<R: Read> fmt::Debug for StreamReader<R> { impl<R: Read> fmt::Debug for StreamReader<R> {
@ -44,7 +44,7 @@ impl<R: Read> StreamReader<R> {
#[deprecated(since="0.28.0", note="wrap you stream into a buffered reader if necessary and use consensus_encode directly")] #[deprecated(since="0.28.0", note="wrap you stream into a buffered reader if necessary and use consensus_encode directly")]
pub fn new(stream: R, _buffer_size: Option<usize>) -> StreamReader<R> { pub fn new(stream: R, _buffer_size: Option<usize>) -> StreamReader<R> {
StreamReader { StreamReader {
stream, stream: BufReader::new(stream),
} }
} }