From dca6cf0aa531312ce8f4aa3c7ffdb4bc89796156 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Mon, 20 Nov 2017 02:14:18 +0100 Subject: [PATCH] Use push_back_non_empty where appropriate. --- server/TracyView.cpp | 54 +++++++++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index b7a085da..48fb983b 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -676,7 +676,7 @@ void View::ProcessFrameMark( const QueueFrameMark& ev ) const auto lastframe = m_frames.back(); const auto time = ev.time * m_timerMul; assert( lastframe < time ); - m_frames.push_back( time ); + m_frames.push_back_non_empty( time ); } void View::ProcessZoneText( const QueueZoneText& ev ) @@ -1069,21 +1069,29 @@ uint32_t View::NewShrinkedSourceLocation( uint64_t srcloc ) void View::InsertMessageData( MessageData* msg, uint64_t thread ) { - if( m_messages.empty() || m_messages.back()->time < msg->time ) + if( m_messages.empty() ) { m_messages.push_back( msg ); } + else if( m_messages.back()->time < msg->time ) + { + m_messages.push_back_non_empty( msg ); + } else { auto mit = std::lower_bound( m_messages.begin(), m_messages.end(), msg->time, [] ( const auto& lhs, const auto& rhs ) { return lhs->time < rhs; } ); m_messages.insert( mit, msg ); } - Vector* vec = &NoticeThread( thread )->messages; - if( vec->empty() || vec->back()->time < msg->time ) + auto vec = &NoticeThread( thread )->messages; + if( vec->empty() ) { vec->push_back( msg ); } + else if( vec->back()->time < msg->time ) + { + vec->push_back_non_empty( msg ); + } else { auto tmit = std::lower_bound( vec->begin(), vec->end(), msg->time, [] ( const auto& lhs, const auto& rhs ) { return lhs->time < rhs; } ); @@ -1148,11 +1156,16 @@ void View::InsertLockEvent( LockMap& lockmap, LockEvent* lev, uint64_t thread ) lev->thread = it->second; assert( lev->thread == it->second ); auto& timeline = lockmap.timeline; - if( timeline.empty() || timeline.back()->time < lev->time ) + if( timeline.empty() ) { timeline.push_back( lev ); UpdateLockCount( lockmap, timeline.size() - 1 ); } + else if( timeline.back()->time < lev->time ) + { + timeline.push_back_non_empty( lev ); + UpdateLockCount( lockmap, timeline.size() - 1 ); + } else { auto it = std::lower_bound( timeline.begin(), timeline.end(), lev->time, [] ( const auto& lhs, const auto& rhs ) { return lhs->time < rhs; } ); @@ -1227,26 +1240,31 @@ void View::InsertPlot( PlotData* plot, PlotItem* item ) const auto& time = item->time; const auto& val = item->val; - if( plot->data.empty() || plot->data.back()->time < time ) + if( plot->data.empty() ) { - if( plot->data.empty() ) - { - plot->min = val; - plot->max = val; - } - else - { - if( plot->min > val ) plot->min = val; - else if( plot->max < val ) plot->max = val; - } + plot->min = val; + plot->max = val; plot->data.push_back( item ); } + else if( plot->data.back()->time < time ) + { + if( plot->min > val ) plot->min = val; + else if( plot->max < val ) plot->max = val; + plot->data.push_back_non_empty( item ); + } else { if( plot->min > val ) plot->min = val; else if( plot->max < val ) plot->max = val; - if( plot->postpone.empty() ) plot->postponeTime = std::chrono::duration_cast( std::chrono::high_resolution_clock::now().time_since_epoch() ).count(); - plot->postpone.push_back( item ); + if( plot->postpone.empty() ) + { + plot->postponeTime = std::chrono::duration_cast( std::chrono::high_resolution_clock::now().time_since_epoch() ).count(); + plot->postpone.push_back( item ); + } + else + { + plot->postpone.push_back_non_empty( item ); + } } }