From 852fe03cbcef3447a72dbe957be43c253ef50f82 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Tue, 29 Jan 2019 22:10:14 +0100 Subject: [PATCH] More references. --- server/TracyView.cpp | 7 ++++--- server/TracyWorker.cpp | 17 ++++++++++------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 369c0fff..921a1106 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -3240,7 +3240,8 @@ int View::DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover, fl showFull = !showFull; } - const auto tr = v->data.back().time - v->data.front().time; + const auto lastTime = v->data.back().time; + const auto tr = lastTime - v->data.front().time; ImGui::BeginTooltip(); ImGui::Text( "Plot \"%s\"", txt ); @@ -3252,8 +3253,8 @@ int View::DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover, fl TextFocused( "Time range:", TimeToString( tr ) ); TextFocused( "Data/second:", RealToString( double( v->data.size() ) / tr * 1000000000ll, true ) ); - const auto it = std::lower_bound( v->data.begin(), v->data.end(), v->data.back().time - 1000000000ll * 10, [] ( const auto& l, const auto& r ) { return l.time < r; } ); - const auto tr10 = v->data.back().time - it->time; + const auto it = std::lower_bound( v->data.begin(), v->data.end(), lastTime - 1000000000ll * 10, [] ( const auto& l, const auto& r ) { return l.time < r; } ); + const auto tr10 = lastTime - it->time; if( tr10 != 0 ) { TextFocused( "D/s (10s):", RealToString( double( std::distance( it, v->data.end() ) ) / tr10 * 1000000000ll, true ) ); diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index 157c6d69..6da2d3a8 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -1168,9 +1168,10 @@ int64_t Worker::GetFrameTime( const FrameData& fd, size_t idx ) const } else { - if( fd.frames[idx].end >= 0 ) + const auto& frame = fd.frames[idx]; + if( frame.end >= 0 ) { - return fd.frames[idx].end - fd.frames[idx].start; + return frame.end - frame.start; } else { @@ -3124,7 +3125,8 @@ void Worker::ReconstructMemAllocPlot() if( aptr != aend && fptr != fend ) { auto atime = aptr->timeAlloc; - auto ftime = mem.data[*fptr].timeFree; + const auto& memData = mem.data[*fptr]; + auto ftime = memData.timeFree; for(;;) { @@ -3142,7 +3144,7 @@ void Worker::ReconstructMemAllocPlot() } else { - usage -= int64_t( mem.data[*fptr].size ); + usage -= int64_t( memData.size ); assert( usage >= 0 ); if( max < usage ) max = usage; ptr->time = ftime; @@ -3150,7 +3152,7 @@ void Worker::ReconstructMemAllocPlot() ptr++; fptr++; if( fptr == fend ) break; - ftime = mem.data[*fptr].timeFree; + ftime = memData.timeFree; } } } @@ -3169,8 +3171,9 @@ void Worker::ReconstructMemAllocPlot() } while( fptr != fend ) { - int64_t time = mem.data[*fptr].timeFree; - usage -= int64_t( mem.data[*fptr].size ); + const auto& memData = mem.data[*fptr]; + int64_t time = memData.timeFree; + usage -= int64_t( memData.size ); assert( usage >= 0 ); assert( max >= usage ); ptr->time = time;