From a421c1239dbb76429b01a22fc4e6f273062ac031 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Tue, 9 Aug 2022 00:06:28 +0100 Subject: [PATCH] Use BufReader/BufWriter for rtsim2 operations --- server/src/rtsim2/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/rtsim2/mod.rs b/server/src/rtsim2/mod.rs index f0aaaf0693..515c0dbd7b 100644 --- a/server/src/rtsim2/mod.rs +++ b/server/src/rtsim2/mod.rs @@ -43,7 +43,7 @@ impl RtSim { match File::open(&file_path) { Ok(file) => { info!("Rtsim state found. Attempting to load..."); - match Data::from_reader(file) { + match Data::from_reader(io::BufReader::new(file)) { Ok(data) => { info!("Rtsim state loaded."); break 'load data }, Err(e) => { error!("Rtsim state failed to load: {}", e); @@ -127,7 +127,7 @@ impl RtSim { .map_err(|e: io::Error| ron::Error::from(e)) .and_then(|(mut file, tmp_file_path)| { info!("Writing rtsim state to file..."); - data.write_to(&mut file)?; + data.write_to(io::BufWriter::new(&mut file))?; file.flush()?; drop(file); fs::rename(tmp_file_path, file_path)?;