Simplify indenting in THIR printing
This cuts >100kb from a local librustc_driver.so build, and seems just obviously simpler.
This commit is contained in:
parent
1bcbb7c93b
commit
8375fe4710
@ -31,8 +31,8 @@ const INDENT: &str = " ";
|
|||||||
|
|
||||||
macro_rules! print_indented {
|
macro_rules! print_indented {
|
||||||
($writer:ident, $s:expr, $indent_lvl:expr) => {
|
($writer:ident, $s:expr, $indent_lvl:expr) => {
|
||||||
let indent = (0..$indent_lvl).map(|_| INDENT).collect::<Vec<_>>().concat();
|
$writer.indent($indent_lvl);
|
||||||
writeln!($writer, "{}{}", indent, $s).expect("unable to write to ThirPrinter");
|
writeln!($writer, "{}", $s).expect("unable to write to ThirPrinter");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,6 +48,12 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> {
|
|||||||
Self { thir, fmt: String::new() }
|
Self { thir, fmt: String::new() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn indent(&mut self, level: usize) {
|
||||||
|
for _ in 0..level {
|
||||||
|
self.fmt.push_str(INDENT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn print(&mut self) {
|
fn print(&mut self) {
|
||||||
print_indented!(self, "params: [", 0);
|
print_indented!(self, "params: [", 0);
|
||||||
for param in self.thir.params.iter() {
|
for param in self.thir.params.iter() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user