Skip to content

Commit

Permalink
Use auto to avoid duplicating type
Browse files Browse the repository at this point in the history
Signed-off-by: Michal Siedlaczek <michal@siedlaczek.me>
  • Loading branch information
elshize committed Jan 7, 2025
1 parent 763be9f commit 55b3c3c
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/progress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void progress::update(std::size_t inc) {

void progress::print_status() {
size_t progress = (100 * m_count) / m_goal;
std::chrono::seconds elapsed =
auto elapsed =
std::chrono::duration_cast<std::chrono::seconds>(std::chrono::steady_clock::now() - m_start);
if (progress != m_progress or elapsed != m_elapsed) {
m_progress = progress;
Expand All @@ -43,12 +43,9 @@ void progress::print_status() {
}

std::ostream& progress::format_interval(std::ostream& out, std::chrono::seconds time) {
using std::chrono::hours;
using std::chrono::minutes;
using std::chrono::seconds;
hours h = std::chrono::duration_cast<hours>(time);
minutes m = std::chrono::duration_cast<minutes>(time - h);
seconds s = std::chrono::duration_cast<seconds>(time - h - m);
auto h = std::chrono::duration_cast<std::chrono::hours>(time);
auto m = std::chrono::duration_cast<std::chrono::minutes>(time - h);
auto s = std::chrono::duration_cast<std::chrono::seconds>(time - h - m);
if (h.count() > 0) {
out << h.count() << "h ";
}
Expand Down

0 comments on commit 55b3c3c

Please sign in to comment.