From 6358b4588d6a697fe870ebda668c5ddbf93640d2 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Mon, 20 Jan 2020 23:40:07 +0100 Subject: [PATCH] Preserve groups order. --- server/TracyView.cpp | 3 ++- server/TracyView.hpp | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 1ee518ca..74f3e46c 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -9202,7 +9202,7 @@ void View::DrawFindZone() auto it = m_findZone.groups.find( gid ); if( it == m_findZone.groups.end() ) { - it = m_findZone.groups.emplace( gid, FindZone::Group {} ).first; + it = m_findZone.groups.emplace( gid, FindZone::Group { m_findZone.groupId++ } ).first; it->second.zones.reserve( 1024 ); } FindZone::Group* group = &it->second; @@ -9222,6 +9222,7 @@ void View::DrawFindZone() switch( m_findZone.sortBy ) { case FindZone::SortBy::Order: + pdqsort_branchless( groups.begin(), groups.end(), []( const auto& lhs, const auto& rhs ) { return lhs->second.id < rhs->second.id; } ); break; case FindZone::SortBy::Count: pdqsort_branchless( groups.begin(), groups.end(), []( const auto& lhs, const auto& rhs ) { return lhs->second.zones.size() > rhs->second.zones.size(); } ); diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 9990920e..a402b557 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -407,6 +407,7 @@ private: struct Group { + uint16_t id; Vector> zones; int64_t time = 0; }; @@ -416,6 +417,7 @@ private: std::vector match; std::map groups; size_t processed; + uint16_t groupId; int selMatch = 0; uint64_t selGroup = Unselected; char pattern[1024] = {}; @@ -480,6 +482,7 @@ private: ResetSelection(); groups.clear(); processed = 0; + groupId = 0; selCs = 0; selGroup = Unselected; }