diff options
author | nobounce <steffen.winter@proton.me> | 2023-09-29 12:20:59 +0200 |
---|---|---|
committer | nobounce <steffen.winter@proton.me> | 2023-09-29 12:26:19 +0200 |
commit | 19dbbe1a17f7e6453709c37a23859e5d73591e53 (patch) | |
tree | b615635fc4f22f5adf7f8231bbb807f9b55d9ad4 | |
parent | 1f72e56c7d6e70f8851134c0a28e17fb0a824a71 (diff) |
Minor string initialization improvement
-rw-r--r-- | src/btop_draw.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/btop_draw.cpp b/src/btop_draw.cpp index 57edda8..c471c52 100644 --- a/src/btop_draw.cpp +++ b/src/btop_draw.cpp @@ -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) + ' ' |