Use buffered read and write for better performance
This commit is contained in:
@@ -76,15 +76,15 @@ impl std::convert::From<std::io::Error> for Error {
|
||||
|
||||
pub fn open_output(output_file: Option<PathBuf>) -> Result<Output, Error> {
|
||||
match output_file {
|
||||
Some(output_path) => Ok(Box::new(std::fs::File::create(output_path)?)),
|
||||
None => Ok(Box::new(std::io::stdout())),
|
||||
Some(output_path) => Ok(Box::new(std::io::BufWriter::new(std::fs::File::create(output_path)?))),
|
||||
None => Ok(Box::new(std::io::BufWriter::new(std::io::stdout()))),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn open_input(input_file: Option<PathBuf>) -> Result<Input, Error> {
|
||||
match input_file {
|
||||
Some(input_path) => Ok(Box::new(std::fs::File::open(input_path)?)),
|
||||
None => Ok(Box::new(std::io::stdin())),
|
||||
Some(input_path) => Ok(Box::new(std::io::BufReader::new(std::fs::File::open(input_path)?))),
|
||||
None => Ok(Box::new(std::io::BufReader::new(std::io::stdin()))),
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user