From: Kostya Shishkov Date: Thu, 10 Sep 2020 12:16:01 +0000 (+0200) Subject: switch to buffered readers and writers X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=f7e9662a6343256ffdf5d1fc6bc7da45f2fb20e6;p=nihav-tool.git switch to buffered readers and writers --- diff --git a/src/main.rs b/src/main.rs index 3f5023a..cbd17d3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,7 +3,7 @@ extern crate nihav_codec_support; extern crate nihav_registry; extern crate nihav_allstuff; -use std::io::{SeekFrom, Write}; +use std::io::{SeekFrom, Write, BufReader}; use std::fs::File; use std::path::Path; use nihav_core::io::byteio::{FileReader, ByteReader}; @@ -164,7 +164,8 @@ fn main() { } let path = Path::new(name); - let mut file = File::open(path).unwrap(); + let file = File::open(path).unwrap(); + let mut file = BufReader::new(file); let dmx_fact; let mut fr = FileReader::new_read(&mut file); let mut br = ByteReader::new(&mut fr); diff --git a/src/wavwriter.rs b/src/wavwriter.rs index a228876..58523b7 100644 --- a/src/wavwriter.rs +++ b/src/wavwriter.rs @@ -61,6 +61,7 @@ macro_rules! write_data { impl<'a> WavWriter<'a> { pub fn new(name: &str) -> Self { let file = File::create(name).unwrap(); + let file = std::io::BufWriter::new(file); let fw = Box::new(FileWriter::new_write(file)); let io = ByteWriter::new(Box::leak(fw)); WavWriter { io: Box::new(io), data_pos: 0, be: false, bits: 0 }