Change zone end "-1" comparisons to "0" comparisons.

This commit is contained in:
Bartosz Taudul 2018-03-24 02:00:20 +01:00
parent 6a4e58b545
commit fea0234a60
3 changed files with 12 additions and 12 deletions

View File

@ -1195,7 +1195,7 @@ int View::DrawZoneLevel( const Vector<ZoneEvent*>& vec, bool hover, double pxns,
if( d > maxdepth ) maxdepth = d; if( d > maxdepth ) maxdepth = d;
} }
if( ev.end != -1 && m_lastCpu != ev.cpu_end ) if( ev.end >= 0 && m_lastCpu != ev.cpu_end )
{ {
m_lastCpu = ev.cpu_end; m_lastCpu = ev.cpu_end;
migration = true; migration = true;
@ -3324,7 +3324,7 @@ void View::DrawFindZone()
while( processed < sz ) while( processed < sz )
{ {
auto& ev = zones[processed]; auto& ev = zones[processed];
if( ev.zone->end == -1 ) break; if( ev.zone->end < 0 ) break;
const auto end = m_worker.GetZoneEndDirect( *ev.zone ); const auto end = m_worker.GetZoneEndDirect( *ev.zone );
const auto timespan = end - ev.zone->start; const auto timespan = end - ev.zone->start;
@ -3603,7 +3603,7 @@ void View::ZoneTooltip( const ZoneEvent& ev )
ImGui::Text( "Without profiling: %s", TimeToString( end - ev.start - m_worker.GetDelay() * dmul ) ); ImGui::Text( "Without profiling: %s", TimeToString( end - ev.start - m_worker.GetDelay() * dmul ) );
if( ev.cpu_start != -1 ) if( ev.cpu_start != -1 )
{ {
if( ev.end == -1 || ev.cpu_start == ev.cpu_end ) if( ev.end < 0 || ev.cpu_start == ev.cpu_end )
{ {
ImGui::Text( "CPU: %i", ev.cpu_start ); ImGui::Text( "CPU: %i", ev.cpu_start );
} }
@ -3659,7 +3659,7 @@ const ZoneEvent* View::GetZoneParent( const ZoneEvent& zone ) const
{ {
auto it = std::upper_bound( timeline->begin(), timeline->end(), zone.start, [] ( const auto& l, const auto& r ) { return l < r->start; } ); auto it = std::upper_bound( timeline->begin(), timeline->end(), zone.start, [] ( const auto& l, const auto& r ) { return l < r->start; } );
if( it != timeline->begin() ) --it; if( it != timeline->begin() ) --it;
if( zone.end != -1 && (*it)->start > zone.end ) break; if( zone.end >= 0 && (*it)->start > zone.end ) break;
if( *it == &zone ) return parent; if( *it == &zone ) return parent;
if( (*it)->child.empty() ) break; if( (*it)->child.empty() ) break;
parent = *it; parent = *it;
@ -3680,7 +3680,7 @@ const GpuEvent* View::GetZoneParent( const GpuEvent& zone ) const
{ {
auto it = std::upper_bound( timeline->begin(), timeline->end(), zone.gpuStart, [] ( const auto& l, const auto& r ) { return l < r->gpuStart; } ); auto it = std::upper_bound( timeline->begin(), timeline->end(), zone.gpuStart, [] ( const auto& l, const auto& r ) { return l < r->gpuStart; } );
if( it != timeline->begin() ) --it; if( it != timeline->begin() ) --it;
if( zone.gpuEnd != -1 && (*it)->gpuStart > zone.gpuEnd ) break; if( zone.gpuEnd >= 0 && (*it)->gpuStart > zone.gpuEnd ) break;
if( *it == &zone ) return parent; if( *it == &zone ) return parent;
if( (*it)->child.empty() ) break; if( (*it)->child.empty() ) break;
parent = *it; parent = *it;
@ -3700,7 +3700,7 @@ uint64_t View::GetZoneThread( const ZoneEvent& zone ) const
{ {
auto it = std::upper_bound( timeline->begin(), timeline->end(), zone.start, [] ( const auto& l, const auto& r ) { return l < r->start; } ); auto it = std::upper_bound( timeline->begin(), timeline->end(), zone.start, [] ( const auto& l, const auto& r ) { return l < r->start; } );
if( it != timeline->begin() ) --it; if( it != timeline->begin() ) --it;
if( zone.end != -1 && (*it)->start > zone.end ) break; if( zone.end >= 0 && (*it)->start > zone.end ) break;
if( *it == &zone ) return thread->id; if( *it == &zone ) return thread->id;
if( (*it)->child.empty() ) break; if( (*it)->child.empty() ) break;
timeline = &(*it)->child; timeline = &(*it)->child;
@ -3719,7 +3719,7 @@ uint64_t View::GetZoneThread( const GpuEvent& zone ) const
{ {
auto it = std::upper_bound( timeline->begin(), timeline->end(), zone.gpuStart, [] ( const auto& l, const auto& r ) { return l < r->gpuStart; } ); auto it = std::upper_bound( timeline->begin(), timeline->end(), zone.gpuStart, [] ( const auto& l, const auto& r ) { return l < r->gpuStart; } );
if( it != timeline->begin() ) --it; if( it != timeline->begin() ) --it;
if( zone.gpuEnd != -1 && (*it)->gpuStart > zone.gpuEnd ) break; if( zone.gpuEnd >= 0 && (*it)->gpuStart > zone.gpuEnd ) break;
if( *it == &zone ) return ctx->thread; if( *it == &zone ) return ctx->thread;
if( (*it)->child.empty() ) break; if( (*it)->child.empty() ) break;
timeline = &(*it)->child; timeline = &(*it)->child;

View File

@ -304,7 +304,7 @@ int64_t Worker::GetZoneEnd( const ZoneEvent& ev )
auto ptr = &ev; auto ptr = &ev;
for(;;) for(;;)
{ {
if( ptr->end != -1 ) return ptr->end; if( ptr->end >= 0 ) return ptr->end;
if( ptr->child.empty() ) return ptr->start; if( ptr->child.empty() ) return ptr->start;
ptr = ptr->child.back(); ptr = ptr->child.back();
} }
@ -315,7 +315,7 @@ int64_t Worker::GetZoneEnd( const GpuEvent& ev )
auto ptr = &ev; auto ptr = &ev;
for(;;) for(;;)
{ {
if( ptr->gpuEnd != -1 ) return ptr->gpuEnd; if( ptr->gpuEnd >= 0 ) return ptr->gpuEnd;
if( ptr->child.empty() ) return ptr->gpuStart; if( ptr->child.empty() ) return ptr->gpuStart;
ptr = ptr->child.back(); ptr = ptr->child.back();
} }
@ -1664,7 +1664,7 @@ void Worker::ReadTimeline( FileRead& f, Vector<ZoneEvent*>& vec, uint16_t thread
assert( it != m_data.sourceLocationZones.end() ); assert( it != m_data.sourceLocationZones.end() );
it->second.zones.push_back( ZoneThreadData { zone, thread } ); it->second.zones.push_back( ZoneThreadData { zone, thread } );
if( zone->end != -1 ) if( zone->end >= 0 )
{ {
const auto timeSpan = zone->end - zone->start; const auto timeSpan = zone->end - zone->start;
if( timeSpan > 0 ) if( timeSpan > 0 )

View File

@ -115,8 +115,8 @@ public:
// GetZoneEndDirect() will only return zone's direct timing data, without looking at children. // GetZoneEndDirect() will only return zone's direct timing data, without looking at children.
static int64_t GetZoneEnd( const ZoneEvent& ev ); static int64_t GetZoneEnd( const ZoneEvent& ev );
static int64_t GetZoneEnd( const GpuEvent& ev ); static int64_t GetZoneEnd( const GpuEvent& ev );
static tracy_force_inline int64_t GetZoneEndDirect( const ZoneEvent& ev ) { return ev.end != -1 ? ev.end : ev.start; } static tracy_force_inline int64_t GetZoneEndDirect( const ZoneEvent& ev ) { return ev.end >= 0 ? ev.end : ev.start; }
static tracy_force_inline int64_t GetZoneEndDirect( const GpuEvent& ev ) { return ev.gpuEnd != -1 ? ev.gpuEnd : ev.gpuStart; } static tracy_force_inline int64_t GetZoneEndDirect( const GpuEvent& ev ) { return ev.gpuEnd >= 0 ? ev.gpuEnd : ev.gpuStart; }
const char* GetString( uint64_t ptr ) const; const char* GetString( uint64_t ptr ) const;
const char* GetString( const StringRef& ref ) const; const char* GetString( const StringRef& ref ) const;