Skip to content

Commit cdd81ca

Browse files
committed
analyze: borrowck: use BufReader/BufWriter for polonius cache save/load
1 parent b3aecb0 commit cdd81ca

File tree

1 file changed

+3
-2
lines changed
  • c2rust-analyze/src/borrowck

1 file changed

+3
-2
lines changed

c2rust-analyze/src/borrowck/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use std::collections::HashMap;
1919
use std::fmt::{Debug, Formatter, Write as _};
2020
use std::fs::{self, File};
2121
use std::hash::{Hash, Hasher};
22+
use std::io::{BufReader, BufWriter};
2223

2324
mod atoms;
2425
mod def_use;
@@ -383,7 +384,7 @@ fn run_polonius<'tcx>(
383384
fn try_load_cached_output(facts_hash: &str) -> Option<Output> {
384385
let path = format!("polonius_cache/{}.output", facts_hash);
385386

386-
let f = File::open(&path).ok()?;
387+
let f = BufReader::new(File::open(&path).ok()?);
387388
let raw = match bincode::deserialize_from(f) {
388389
Ok(x) => x,
389390
Err(e) => {
@@ -492,7 +493,7 @@ fn save_cached_output(facts_hash: &str, output: &Output) -> Result<(), bincode::
492493
),
493494
);
494495

495-
let f = File::create(path)?;
496+
let f = BufWriter::new(File::create(path)?);
496497
bincode::serialize_into(f, &raw)
497498
}
498499

0 commit comments

Comments
 (0)