From 71b175d4edcf9a6fb6b391b833640005158215df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kleines=20Filmr=C3=B6llchen?= Date: Tue, 26 Apr 2022 22:59:03 +0200 Subject: [PATCH] Profiler: Use ProfileModel rounding constant for the status bar text This way, we can change the constant in one place. Note that this requires the use of nested format strings, which is slightly ugly but safe to do in this instance. --- Userland/DevTools/Profiler/main.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Userland/DevTools/Profiler/main.cpp b/Userland/DevTools/Profiler/main.cpp index 53aca5e915..684f9361cb 100644 --- a/Userland/DevTools/Profiler/main.cpp +++ b/Userland/DevTools/Profiler/main.cpp @@ -222,9 +222,11 @@ ErrorOr serenity_main(Main::Arguments arguments) return min(end_of_trace, max(timestamp, start_of_trace)); }; - auto const format_sample_count = [&profile](auto sample_count) { + // FIXME: Make this constexpr once String is able to. + auto const sample_count_percent_format_string = String::formatted("{{:.{}f}}%", number_of_percent_digits); + auto const format_sample_count = [&profile, sample_count_percent_format_string](auto const sample_count) { if (profile->show_percentages()) - return String::formatted("{:.3f}%", sample_count.as_float_or(0.0)); + return String::formatted(sample_count_percent_format_string, sample_count.as_float_or(0.0)); return String::formatted("{} Samples", sample_count.to_i32()); };