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 57f90fe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
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
2 changes: 1 addition & 1 deletion ethers-solc/src/compile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use semver::{Version, VersionReq};
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use std::{
fmt,
io::BufRead,
io::{BufRead, Write},
path::{Path, PathBuf},
process::{Command, Output, Stdio},
str::FromStr,
Expand Down

0 comments on commit 57f90fe

Please sign in to comment.