diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 308a0421..d333bdc9 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -5689,38 +5689,39 @@ void View::DrawFindZone() Vector* zonesToIterate = &v->second.zones; Vector sortedZones; - if ( m_findZone.tableSortBy != FindZone::TableSortBy::Starttime ) + if( m_findZone.tableSortBy != FindZone::TableSortBy::Starttime ) { zonesToIterate = &sortedZones; sortedZones.reserve_and_use( v->second.zones.size() ); - memcpy(sortedZones.data(), v->second.zones.data(), sizeof(ZoneEvent*)*v->second.zones.size()); + memcpy( sortedZones.data(), v->second.zones.data(), v->second.zones.size() * sizeof( ZoneEvent* ) ); switch( m_findZone.tableSortBy ) { case FindZone::TableSortBy::Runtime: if( m_findZone.selfTime ) - pdqsort_branchless( sortedZones.begin(), sortedZones.end(), [this]( const auto& lhs, const auto& rhs ) - { - return (m_worker.GetZoneEndDirect( *lhs ) - lhs->start - GetZoneChildTimeFast( *lhs )) - > - (m_worker.GetZoneEndDirect( *rhs ) - rhs->start - GetZoneChildTimeFast( *rhs )); - } ); + { + pdqsort_branchless( sortedZones.begin(), sortedZones.end(), [this]( const auto& lhs, const auto& rhs ) { + return m_worker.GetZoneEndDirect( *lhs ) - lhs->start - GetZoneChildTimeFast( *lhs ) > + m_worker.GetZoneEndDirect( *rhs ) - rhs->start - GetZoneChildTimeFast( *rhs ); + } ); + } else - pdqsort_branchless( sortedZones.begin(), sortedZones.end(), [this]( const auto& lhs, const auto& rhs ) { return (m_worker.GetZoneEndDirect( *lhs ) - lhs->start) > (m_worker.GetZoneEndDirect( *rhs ) - rhs->start); } ); + { + pdqsort_branchless( sortedZones.begin(), sortedZones.end(), [this]( const auto& lhs, const auto& rhs ) { + return m_worker.GetZoneEndDirect( *lhs ) - lhs->start > m_worker.GetZoneEndDirect( *rhs ) - rhs->start; + } ); + } break; case FindZone::TableSortBy::Name: - pdqsort_branchless( sortedZones.begin(), sortedZones.end(), [this]( const auto& lhs, const auto& rhs ) - { - if (lhs->name.active != rhs->name.active) return lhs->name.active > rhs->name.active; - - return strcmp(m_worker.GetString( lhs->name ), m_worker.GetString( rhs->name )) < 0; - } ); + pdqsort_branchless( sortedZones.begin(), sortedZones.end(), [this]( const auto& lhs, const auto& rhs ) { + if( lhs->name.active != rhs->name.active ) return lhs->name.active > rhs->name.active; + return strcmp( m_worker.GetString( lhs->name ), m_worker.GetString( rhs->name ) ) < 0; + } ); break; default: assert( false ); break; } - } for( auto& ev : *zonesToIterate )