Skip to content

Commit 5248b20

Browse files
committed
Reuse memory
1 parent a21f3a7 commit 5248b20

File tree

1 file changed

+5
-2
lines changed
  • compiler/rustc_graphviz/src

1 file changed

+5
-2
lines changed

compiler/rustc_graphviz/src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,13 +653,13 @@ where
653653
writeln!(w, r#" edge[{}];"#, content_attrs_str)?;
654654
}
655655

656+
let mut text = Vec::new();
656657
for n in g.nodes().iter() {
657658
write!(w, " ")?;
658659
let id = g.node_id(n);
659660

660661
let escaped = &g.node_label(n).to_dot_string();
661662

662-
let mut text = Vec::new();
663663
write!(text, "{}", id.as_slice()).unwrap();
664664

665665
if !options.contains(&RenderOption::NoNodeLabels) {
@@ -677,6 +677,8 @@ where
677677

678678
writeln!(text, ";").unwrap();
679679
w.write_all(&text[..])?;
680+
681+
text.clear();
680682
}
681683

682684
for e in g.edges().iter() {
@@ -687,7 +689,6 @@ where
687689
let source_id = g.node_id(&source);
688690
let target_id = g.node_id(&target);
689691

690-
let mut text = Vec::new();
691692
write!(text, "{} -> {}", source_id.as_slice(), target_id.as_slice()).unwrap();
692693

693694
if !options.contains(&RenderOption::NoEdgeLabels) {
@@ -701,6 +702,8 @@ where
701702

702703
writeln!(text, ";").unwrap();
703704
w.write_all(&text[..])?;
705+
706+
text.clear();
704707
}
705708

706709
writeln!(w, "}}")

0 commit comments

Comments
 (0)