From f7829a7eaebb10ba2ed326da9e5d135e0660a662 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 4 Mar 2018 22:11:50 +0100 Subject: [PATCH] Store matches in a map. --- server/TracyView.cpp | 29 ++++++++++++++++------------- server/TracyView.hpp | 3 +-- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index e327851a..b6cfba98 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -2674,7 +2674,6 @@ void View::DrawFindZone() { m_findZone.result.clear(); m_findZone.match.clear(); - m_findZone.matchEnable.clear(); } if( ImGui::TreeNode( "Options" ) ) @@ -2692,7 +2691,6 @@ void View::DrawFindZone() { m_findZone.result.clear(); m_findZone.match.clear(); - m_findZone.matchEnable.clear(); FindZones(); } @@ -2701,18 +2699,19 @@ void View::DrawFindZone() ImGui::Separator(); if( ImGui::TreeNode( "Matched source locations" ) ) { - for( size_t i=0; i( m_findZone.match.size(), true ); + m_findZone.match.reserve( match.size() ); + for( auto& v : match ) + { + m_findZone.match.emplace( v, true ); + } RecalcFindMatches(); } @@ -3296,8 +3299,8 @@ void View::RecalcFindMatches( const Vector& events, Vector= m_findZone.maxZonesPerThread ) break; if( m_worker.GetZoneEnd( *ev ) == ev->start ) continue; - auto it = std::find( m_findZone.match.begin(), m_findZone.match.end(), ev->srcloc ); - if( it != m_findZone.match.end() && m_findZone.matchEnable[std::distance( m_findZone.match.begin(), it )] ) + auto it = m_findZone.match.find( ev->srcloc ); + if( it != m_findZone.match.end() && it->second ) { out.push_back( ev ); } diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 46e2e49b..91134e17 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -164,8 +164,7 @@ private: struct { bool show; std::vector> result; - std::vector match; - std::vector matchEnable; + flat_hash_map match; char pattern[1024] = { "" }; int maxZonesPerThread = -1; int maxDepth = -1;