From f7e9662a6343256ffdf5d1fc6bc7da45f2fb20e6 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Thu, 10 Sep 2020 14:16:01 +0200 Subject: [PATCH] switch to buffered readers and writers --- src/main.rs | 5 +++-- src/wavwriter.rs | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) 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 } -- 2.39.5