mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Use BufReader/BufWriter for rtsim2 operations
This commit is contained in:
parent
c168ff2f9b
commit
a421c1239d
@ -43,7 +43,7 @@ impl RtSim {
|
|||||||
match File::open(&file_path) {
|
match File::open(&file_path) {
|
||||||
Ok(file) => {
|
Ok(file) => {
|
||||||
info!("Rtsim state found. Attempting to load...");
|
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 },
|
Ok(data) => { info!("Rtsim state loaded."); break 'load data },
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("Rtsim state failed to load: {}", e);
|
error!("Rtsim state failed to load: {}", e);
|
||||||
@ -127,7 +127,7 @@ impl RtSim {
|
|||||||
.map_err(|e: io::Error| ron::Error::from(e))
|
.map_err(|e: io::Error| ron::Error::from(e))
|
||||||
.and_then(|(mut file, tmp_file_path)| {
|
.and_then(|(mut file, tmp_file_path)| {
|
||||||
info!("Writing rtsim state to file...");
|
info!("Writing rtsim state to file...");
|
||||||
data.write_to(&mut file)?;
|
data.write_to(io::BufWriter::new(&mut file))?;
|
||||||
file.flush()?;
|
file.flush()?;
|
||||||
drop(file);
|
drop(file);
|
||||||
fs::rename(tmp_file_path, file_path)?;
|
fs::rename(tmp_file_path, file_path)?;
|
||||||
|
Loading…
Reference in New Issue
Block a user