Skip to content

Commit 6597cb4

Browse files
authored
perf: avoid serde_json::from_reader (foundry-rs#5602)
1 parent 52860c8 commit 6597cb4

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

evm/src/executor/fork/cache.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,12 +330,11 @@ impl JsonBlockCacheDB {
330330
pub fn load(path: impl Into<PathBuf>) -> eyre::Result<Self> {
331331
let path = path.into();
332332
trace!(target : "cache", ?path, "reading json cache");
333-
let file = fs::File::open(&path).map_err(|err| {
333+
let contents = std::fs::read_to_string(&path).map_err(|err| {
334334
warn!(?err, ?path, "Failed to read cache file");
335335
err
336336
})?;
337-
let file = std::io::BufReader::new(file);
338-
let data = serde_json::from_reader(file).map_err(|err| {
337+
let data = serde_json::from_str(&contents).map_err(|err| {
339338
warn!(target : "cache", ?err, ?path, "Failed to deserialize cache data");
340339
err
341340
})?;

0 commit comments

Comments
 (0)