Skip to content

Commit 6071372

Browse files
committed
Use std::iter repeat to generate indentation level
1 parent 44c760d commit 6071372

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/cargo/util/profile.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::os;
22
use std::mem;
33
use std::fmt::Show;
44
use time;
5+
use std::iter::repeat;
56
use std::cell::RefCell;
67

78
thread_local!(static PROFILE_STACK: RefCell<Vec<u64>> = RefCell::new(Vec::new()));
@@ -38,13 +39,8 @@ impl Drop for Profiler {
3839
let mut last = 0;
3940
for (i, &(l, time, ref msg)) in msgs.iter().enumerate() {
4041
if l != lvl { continue }
41-
42-
let mut spaces = String::new();
43-
for _ in range(0u, lvl + 1) {
44-
spaces.push_str(" ");
45-
}
46-
47-
println!("{} {:6}ms - {}", spaces, time / 1000000, msg);
42+
println!("{} {:6}ms - {}", repeat(" ").take(lvl + 1).collect::<String>(),
43+
time / 1000000, msg);
4844

4945
print(lvl + 1, msgs.slice(last, i));
5046
last = i;

0 commit comments

Comments
 (0)