about summary refs log tree commit diff
path: root/compiler/rustc_graphviz
diff options
context:
space:
mode:
authorDániel Buga <bugadani@gmail.com>2020-10-28 17:04:44 +0100
committerDániel Buga <bugadani@gmail.com>2020-10-28 17:22:10 +0100
commit5248b20d9ae02a39cb20448896fc663636f591fc (patch)
treec196ff8955e3ce11837bd525af10dfd58029cf50 /compiler/rustc_graphviz
parenta21f3a76a9f5c1f7087e9aec6102889cb24a0b77 (diff)
downloadrust-5248b20d9ae02a39cb20448896fc663636f591fc.tar.gz
rust-5248b20d9ae02a39cb20448896fc663636f591fc.zip
Reuse memory
Diffstat (limited to 'compiler/rustc_graphviz')
-rw-r--r--compiler/rustc_graphviz/src/lib.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/compiler/rustc_graphviz/src/lib.rs b/compiler/rustc_graphviz/src/lib.rs
index 76e33bed97f..d332466160c 100644
--- a/compiler/rustc_graphviz/src/lib.rs
+++ b/compiler/rustc_graphviz/src/lib.rs
@@ -653,13 +653,13 @@ where
         writeln!(w, r#"    edge[{}];"#, content_attrs_str)?;
     }
 
+    let mut text = Vec::new();
     for n in g.nodes().iter() {
         write!(w, "    ")?;
         let id = g.node_id(n);
 
         let escaped = &g.node_label(n).to_dot_string();
 
-        let mut text = Vec::new();
         write!(text, "{}", id.as_slice()).unwrap();
 
         if !options.contains(&RenderOption::NoNodeLabels) {
@@ -677,6 +677,8 @@ where
 
         writeln!(text, ";").unwrap();
         w.write_all(&text[..])?;
+
+        text.clear();
     }
 
     for e in g.edges().iter() {
@@ -687,7 +689,6 @@ where
         let source_id = g.node_id(&source);
         let target_id = g.node_id(&target);
 
-        let mut text = Vec::new();
         write!(text, "{} -> {}", source_id.as_slice(), target_id.as_slice()).unwrap();
 
         if !options.contains(&RenderOption::NoEdgeLabels) {
@@ -701,6 +702,8 @@ where
 
         writeln!(text, ";").unwrap();
         w.write_all(&text[..])?;
+
+        text.clear();
     }
 
     writeln!(w, "}}")