Skip to content

Commit 9e475da

Browse files
committed
Auto merge of #118341 - Mark-Simulacrum:shrink-thir-print, r=<try>
Simplify indenting in THIR printing This cuts >100kb from a local librustc_driver.so build, and seems just obviously simpler.
2 parents 6cf0888 + 8375fe4 commit 9e475da

File tree

1 file changed

+8
-2
lines changed
  • compiler/rustc_mir_build/src/thir

1 file changed

+8
-2
lines changed

compiler/rustc_mir_build/src/thir/print.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ const INDENT: &str = " ";
3131

3232
macro_rules! print_indented {
3333
($writer:ident, $s:expr, $indent_lvl:expr) => {
34-
let indent = (0..$indent_lvl).map(|_| INDENT).collect::<Vec<_>>().concat();
35-
writeln!($writer, "{}{}", indent, $s).expect("unable to write to ThirPrinter");
34+
$writer.indent($indent_lvl);
35+
writeln!($writer, "{}", $s).expect("unable to write to ThirPrinter");
3636
};
3737
}
3838

@@ -48,6 +48,12 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> {
4848
Self { thir, fmt: String::new() }
4949
}
5050

51+
fn indent(&mut self, level: usize) {
52+
for _ in 0..level {
53+
self.fmt.push_str(INDENT);
54+
}
55+
}
56+
5157
fn print(&mut self) {
5258
print_indented!(self, "params: [", 0);
5359
for param in self.thir.params.iter() {

0 commit comments

Comments
 (0)