From 37808ec4c79278d164fbb655b2fb09848cf61550 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Tue, 20 Mar 2018 15:33:38 +0100 Subject: [PATCH] Fix the horribly inefficient Visible() and ShowFull() methods. --- server/TracyView.hpp | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 2e5fa547..8448b6b7 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -103,28 +103,27 @@ private: void FindZones(); #endif - template - bool& Visible( const T* ptr ) - { - static std::map visible; - if( visible.find( ptr ) == visible.end() ) - { - visible[ptr] = true; - } + flat_hash_map> m_visible; + flat_hash_map> m_showFull; - return visible[ptr]; + tracy_force_inline bool& Visible( const void* ptr ) + { + auto it = m_visible.find( ptr ); + if( it == m_visible.end() ) + { + it = m_visible.emplace( ptr, true ).first; + } + return it->second; } - template - bool& ShowFull( const T* ptr ) + tracy_force_inline bool& ShowFull( const void* ptr ) { - static std::map showFull; - if( showFull.find( ptr ) == showFull.end() ) + auto it = m_showFull.find( ptr ); + if( it == m_showFull.end() ) { - showFull[ptr] = true; + it = m_showFull.emplace( ptr, true ).first; } - - return showFull[ptr]; + return it->second; } Worker m_worker;