Skip to content

Commit

Permalink
Merge pull request aristocratos#636 from nobounce/performance-iili
Browse files Browse the repository at this point in the history
Minor string initialization improvement
  • Loading branch information
aristocratos authored Sep 30, 2023
2 parents 1f72e56 + 19dbbe1 commit 52bfff7
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/btop_draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1532,12 +1532,13 @@ namespace Proc {
}

// Shorten process thread representation when larger than 5 digits: 10000 -> 10K ...
std::string proc_threads_string;
if (p.threads > 9999) {
proc_threads_string = std::to_string(p.threads / 1000) + 'K';
} else {
proc_threads_string = std::to_string(p.threads);
}
const std::string proc_threads_string = [&] {
if (p.threads > 9999) {
return std::to_string(p.threads / 1000) + 'K';
} else {
return std::to_string(p.threads);
}
}();

out += (thread_size > 0 ? t_color + rjust(proc_threads_string, thread_size) + ' ' + end : "" )
+ g_color + ljust((cmp_greater(p.user.size(), user_size) ? p.user.substr(0, user_size - 1) + '+' : p.user), user_size) + ' '
Expand Down

0 comments on commit 52bfff7

Please sign in to comment.