Skip to content

Commit a76ff49

Browse files
authored
Rollup merge of #62164 - jsgf:buffer-save-analysis, r=Xanewok
save-analysis: use buffered writes Otherwise it ends up writing the file byte at a time, which can be very slow for large outputs. cc @ljw1004
2 parents a94c5dd + 768d500 commit a76ff49

File tree

1 file changed

+4
-3
lines changed
  • src/librustc_save_analysis

1 file changed

+4
-3
lines changed

src/librustc_save_analysis/lib.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use std::cell::Cell;
2929
use std::default::Default;
3030
use std::env;
3131
use std::fs::File;
32+
use std::io::BufWriter;
3233
use std::path::{Path, PathBuf};
3334

3435
use syntax::ast::{self, Attribute, DUMMY_NODE_ID, NodeId, PatKind};
@@ -1025,7 +1026,7 @@ impl<'a> DumpHandler<'a> {
10251026
}
10261027
}
10271028

1028-
fn output_file(&self, ctx: &SaveContext<'_, '_>) -> (File, PathBuf) {
1029+
fn output_file(&self, ctx: &SaveContext<'_, '_>) -> (BufWriter<File>, PathBuf) {
10291030
let sess = &ctx.tcx.sess;
10301031
let file_name = match ctx.config.output_file {
10311032
Some(ref s) => PathBuf::from(s),
@@ -1059,9 +1060,9 @@ impl<'a> DumpHandler<'a> {
10591060

10601061
info!("Writing output to {}", file_name.display());
10611062

1062-
let output_file = File::create(&file_name).unwrap_or_else(
1063+
let output_file = BufWriter::new(File::create(&file_name).unwrap_or_else(
10631064
|e| sess.fatal(&format!("Could not open {}: {}", file_name.display(), e)),
1064-
);
1065+
));
10651066

10661067
(output_file, file_name)
10671068
}

0 commit comments

Comments
 (0)