about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorljedrz <ljedrz@gmail.com>2018-10-12 13:55:35 +0200
committerljedrz <ljedrz@gmail.com>2018-10-12 13:55:35 +0200
commit5bfe08fc718cd8ecfaa5696261b5eea07a2a5d96 (patch)
treed591a8ed7d1a1bc1b79a5a7e35dc8df150189cd5 /src
parent71d3a715721137ffc10becc10978fe038ee131ac (diff)
downloadrust-5bfe08fc718cd8ecfaa5696261b5eea07a2a5d96.tar.gz
rust-5bfe08fc718cd8ecfaa5696261b5eea07a2a5d96.zip
rustc/driver: simplify profile::trace::cons
Diffstat (limited to 'src')
-rw-r--r--src/librustc_driver/profile/trace.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/librustc_driver/profile/trace.rs b/src/librustc_driver/profile/trace.rs
index e329b037d22..7896195a742 100644
--- a/src/librustc_driver/profile/trace.rs
+++ b/src/librustc_driver/profile/trace.rs
@@ -43,18 +43,18 @@ pub struct QueryMetric {
     pub dur_total: Duration,
 }
 
+fn cons(s: &str) -> String {
+    let first = s.split(|d| d == '(' || d == '{').next();
+    assert!(first.is_some() && first != Some(""));
+    first.unwrap().to_owned()
+}
+
 pub fn cons_of_query_msg(q: &trace::Query) -> String {
-    let s = format!("{:?}", q.msg);
-    let cons: Vec<&str> = s.split(|d| d == '(' || d == '{').collect();
-    assert!(cons.len() > 0 && cons[0] != "");
-    cons[0].to_string()
+    cons(&format!("{:?}", q.msg))
 }
 
 pub fn cons_of_key(k: &DepNode) -> String {
-    let s = format!("{:?}", k);
-    let cons: Vec<&str> = s.split(|d| d == '(' || d == '{').collect();
-    assert!(cons.len() > 0 && cons[0] != "");
-    cons[0].to_string()
+    cons(&format!("{:?}", k))
 }
 
 // First return value is text; second return value is a CSS class