From c4c43ef7fe2b3f53f777718be70d60c8fc7397ef Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Thu, 23 Dec 2021 15:15:49 +0100 Subject: [PATCH] Take rounding into consideration. --- server/TracySourceView.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/server/TracySourceView.cpp b/server/TracySourceView.cpp index e36b8d50..e7a2a37f 100644 --- a/server/TracySourceView.cpp +++ b/server/TracySourceView.cpp @@ -4099,19 +4099,17 @@ void SourceView::RenderHwLinePart( size_t cycles, size_t retired, size_t branchR else { char buf[16]; - if( rate >= 0.1f ) + const auto end = PrintFloat( buf, buf+16, rate * 100, 1 ); + memcpy( end, "%", 2 ); + if( end - buf == 4 ) { - const auto end = PrintFloat( buf, buf+16, rate * 100, 1 ); - assert( end == buf+4 ); + TextColoredUnformatted( col, buf ); } else { - *buf = ' '; - const auto end = PrintFloat( buf+1, buf+16, rate * 100, 1 ); - assert( end == buf+4 ); + ImGui::SameLine( 0, ts.x ); + TextColoredUnformatted( col, buf ); } - memcpy( buf+4, "%", 2 ); - TextColoredUnformatted( col, buf ); } if( ImGui::IsItemHovered() ) {