From 92f0bc29355ac990595e1771c4bb9a3b7e358d30 Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Tue, 18 Mar 2014 23:40:07 +1100 Subject: [PATCH] rustc: buffer the output writer for -Z ast-json[-noexpand]. This takes the time for `rustc libstd/lib.rs -Z ast-json-noexpand > file.json` from 9.0s to 3.5s (~0.5s spent parsing etc.) and `-Z ast-json` from 11s to 5s (~1.5s spent parsing and expanding). --- src/librustc/driver/driver.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index e7c1e214d07..5926f535ad8 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -186,7 +186,7 @@ pub fn phase_1_parse_input(sess: &Session, cfg: ast::CrateConfig, input: &Input) }); if sess.opts.debugging_opts & session::AST_JSON_NOEXPAND != 0 { - let mut stdout = io::stdout(); + let mut stdout = io::BufferedWriter::new(io::stdout()); let mut json = json::PrettyEncoder::new(&mut stdout); krate.encode(&mut json); } @@ -261,7 +261,7 @@ pub fn phase_2_configure_and_expand(sess: &Session, front::assign_node_ids_and_map::assign_node_ids_and_map(sess, krate)); if sess.opts.debugging_opts & session::AST_JSON != 0 { - let mut stdout = io::stdout(); + let mut stdout = io::BufferedWriter::new(io::stdout()); let mut json = json::PrettyEncoder::new(&mut stdout); krate.encode(&mut json); }