Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
perf: buffer writes when serializing json
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes committed Aug 12, 2023
1 parent 5145992 commit b89a810
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ethers-solc/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use std::{
hash_map, BTreeSet, HashMap, HashSet,
},
fs::{self},
io::Write,
path::{Path, PathBuf},
time::{Duration, UNIX_EPOCH},
};
Expand Down Expand Up @@ -139,7 +140,9 @@ impl SolFilesCache {
self.len(),
path.display()
);
serde_json::to_writer_pretty(file, self)?;
let mut writer = std::io::BufWriter::with_capacity(1024 * 256, file);
serde_json::to_writer_pretty(&mut writer, self)?;
writer.flush().map_err(|e| SolcError::io(e, path))?;
tracing::trace!("cache file located: \"{}\"", path.display());
Ok(())
}
Expand Down

0 comments on commit b89a810

Please sign in to comment.