Skip to content

Commit

Permalink
Auto merge of #5507 - ordovicia:no-secs-frac, r=matklad
Browse files Browse the repository at this point in the history
Does not print seconds fraction with minutes

As discussed in #5456 (comment),
seconds fraction seems unnecessary when the elapsed time is reported in minutes.
  • Loading branch information
bors committed May 10, 2018
2 parents caa7ac1 + 73941b0 commit af08be9
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions src/cargo/core/compiler/job_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,26 +276,14 @@ impl<'a> JobQueue<'a> {
}

let time_elapsed = {
use std::fmt::Write;

let duration = cx.bcx.config.creation_time().elapsed();
let mut s = String::new();
let secs = duration.as_secs();

if secs >= 60 {
// We can safely unwrap, as writing to a `String` never errors
write!(s, "{}m ", secs / 60).unwrap();
};

// We can safely unwrap, as writing to a `String` never errors
write!(
s,
"{}.{:02}s",
secs % 60,
duration.subsec_nanos() / 10_000_000
).unwrap();

s
format!("{}m {:02}s", secs / 60, secs % 60)
} else {
format!("{}.{:02}s", secs, duration.subsec_nanos() / 10_000_000)
}
};

if self.queue.is_empty() {
Expand Down

0 comments on commit af08be9

Please sign in to comment.