Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 5bfe08f

Browse files
committed
rustc/driver: simplify profile::trace::cons
1 parent 71d3a71 commit 5bfe08f

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/librustc_driver/profile/trace.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,18 @@ pub struct QueryMetric {
4343
pub dur_total: Duration,
4444
}
4545

46+
fn cons(s: &str) -> String {
47+
let first = s.split(|d| d == '(' || d == '{').next();
48+
assert!(first.is_some() && first != Some(""));
49+
first.unwrap().to_owned()
50+
}
51+
4652
pub fn cons_of_query_msg(q: &trace::Query) -> String {
47-
let s = format!("{:?}", q.msg);
48-
let cons: Vec<&str> = s.split(|d| d == '(' || d == '{').collect();
49-
assert!(cons.len() > 0 && cons[0] != "");
50-
cons[0].to_string()
53+
cons(&format!("{:?}", q.msg))
5154
}
5255

5356
pub fn cons_of_key(k: &DepNode) -> String {
54-
let s = format!("{:?}", k);
55-
let cons: Vec<&str> = s.split(|d| d == '(' || d == '{').collect();
56-
assert!(cons.len() > 0 && cons[0] != "");
57-
cons[0].to_string()
57+
cons(&format!("{:?}", k))
5858
}
5959

6060
// First return value is text; second return value is a CSS class

0 commit comments

Comments
 (0)