Skip to content

Commit 92f0bc2

Browse files
huonwalexcrichton
authored andcommitted
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).
1 parent 873f740 commit 92f0bc2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/librustc/driver/driver.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ pub fn phase_1_parse_input(sess: &Session, cfg: ast::CrateConfig, input: &Input)
186186
});
187187

188188
if sess.opts.debugging_opts & session::AST_JSON_NOEXPAND != 0 {
189-
let mut stdout = io::stdout();
189+
let mut stdout = io::BufferedWriter::new(io::stdout());
190190
let mut json = json::PrettyEncoder::new(&mut stdout);
191191
krate.encode(&mut json);
192192
}
@@ -261,7 +261,7 @@ pub fn phase_2_configure_and_expand(sess: &Session,
261261
front::assign_node_ids_and_map::assign_node_ids_and_map(sess, krate));
262262

263263
if sess.opts.debugging_opts & session::AST_JSON != 0 {
264-
let mut stdout = io::stdout();
264+
let mut stdout = io::BufferedWriter::new(io::stdout());
265265
let mut json = json::PrettyEncoder::new(&mut stdout);
266266
krate.encode(&mut json);
267267
}

0 commit comments

Comments
 (0)