Fix the horribly inefficient Visible() and ShowFull() methods.

This commit is contained in:
Bartosz Taudul 2018-03-20 15:33:38 +01:00
parent ceeae3c2cf
commit 37808ec4c7

View File

@ -103,28 +103,27 @@ private:
void FindZones(); void FindZones();
#endif #endif
template <typename T> flat_hash_map<const void*, bool, nohash<const void*>> m_visible;
bool& Visible( const T* ptr ) flat_hash_map<const void*, bool, nohash<const void*>> m_showFull;
{
static std::map <const T*, bool> visible;
if( visible.find( ptr ) == visible.end() )
{
visible[ptr] = true;
}
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 <typename T> tracy_force_inline bool& ShowFull( const void* ptr )
bool& ShowFull( const T* ptr )
{ {
static std::map <const T*, bool> showFull; auto it = m_showFull.find( ptr );
if( showFull.find( ptr ) == showFull.end() ) if( it == m_showFull.end() )
{ {
showFull[ptr] = true; it = m_showFull.emplace( ptr, true ).first;
} }
return it->second;
return showFull[ptr];
} }
Worker m_worker; Worker m_worker;