diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-06-27 23:01:17 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-06-27 23:01:17 +0200 |
| commit | dec2c8bd16b8a525a24260f03da1d131f659ce94 (patch) | |
| tree | ad57c982eaca20b43b13314f31bec7d5555df122 | |
| parent | fdf75af730c7e661b00df4c36f73f6fa564396ea (diff) | |
| parent | 768d5001575091dd298fbfce3b7b03a3c3faf117 (diff) | |
| download | rust-dec2c8bd16b8a525a24260f03da1d131f659ce94.tar.gz rust-dec2c8bd16b8a525a24260f03da1d131f659ce94.zip | |
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
| -rw-r--r-- | src/librustc_save_analysis/lib.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index 19ed9e21407..ab82f75f74f 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -29,6 +29,7 @@ use std::cell::Cell; use std::default::Default; use std::env; use std::fs::File; +use std::io::BufWriter; use std::path::{Path, PathBuf}; use syntax::ast::{self, Attribute, DUMMY_NODE_ID, NodeId, PatKind}; @@ -1025,7 +1026,7 @@ impl<'a> DumpHandler<'a> { } } - fn output_file(&self, ctx: &SaveContext<'_, '_>) -> (File, PathBuf) { + fn output_file(&self, ctx: &SaveContext<'_, '_>) -> (BufWriter<File>, PathBuf) { let sess = &ctx.tcx.sess; let file_name = match ctx.config.output_file { Some(ref s) => PathBuf::from(s), @@ -1059,9 +1060,9 @@ impl<'a> DumpHandler<'a> { info!("Writing output to {}", file_name.display()); - let output_file = File::create(&file_name).unwrap_or_else( + let output_file = BufWriter::new(File::create(&file_name).unwrap_or_else( |e| sess.fatal(&format!("Could not open {}: {}", file_name.display(), e)), - ); + )); (output_file, file_name) } |
