diff options
author | Bartosz Taudul <wolf@nereid.pl> | 2021-11-29 21:23:31 +0300 |
---|---|---|
committer | Bartosz Taudul <wolf@nereid.pl> | 2021-11-29 21:23:31 +0300 |
commit | 5c379603b5e3d02f6e6c217d1c9c18b5e37f68d2 (patch) | |
tree | 461f2f89569a4859b3d1290d356b8a913de3d80d | |
parent | 04f045b22b03cd4272770788e6fb8d1416edff2c (diff) |
Move onlyActive check out of the loops.
-rw-r--r-- | server/TracyView.cpp | 82 |
1 files changed, 60 insertions, 22 deletions
diff --git a/server/TracyView.cpp b/server/TracyView.cpp index a33fbb5f..712fa509 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -17049,42 +17049,80 @@ unordered_flat_map<uint32_t, View::MemPathData> View::GetCallstackPaths( const M if( it != mem.data.end() ) { auto end = std::lower_bound( mem.data.begin(), mem.data.end(), m_memInfo.range.max, []( const auto& lhs, const auto& rhs ) { return lhs.TimeAlloc() < rhs; } ); - while( it != end ) + if( onlyActive ) { - auto& ev = *it++; - - if( ev.CsAlloc() == 0 ) continue; - if( onlyActive && ev.TimeFree() >= 0 && ev.TimeFree() < m_memInfo.range.max ) continue; - - auto pit = pathSum.find( ev.CsAlloc() ); - if( pit == pathSum.end() ) + while( it != end ) { - pathSum.emplace( ev.CsAlloc(), MemPathData { 1, ev.Size() } ); + auto& ev = *it++; + if( ev.CsAlloc() == 0 ) continue; + if( ev.TimeFree() >= 0 && ev.TimeFree() < m_memInfo.range.max ) continue; + auto pit = pathSum.find( ev.CsAlloc() ); + if( pit == pathSum.end() ) + { + pathSum.emplace( ev.CsAlloc(), MemPathData { 1, ev.Size() } ); + } + else + { + pit->second.cnt++; + pit->second.mem += ev.Size(); + } } - else + } + else + { + while( it != end ) { - pit->second.cnt++; - pit->second.mem += ev.Size(); + auto& ev = *it++; + if( ev.CsAlloc() == 0 ) continue; + auto pit = pathSum.find( ev.CsAlloc() ); + if( pit == pathSum.end() ) + { + pathSum.emplace( ev.CsAlloc(), MemPathData { 1, ev.Size() } ); + } + else + { + pit->second.cnt++; + pit->second.mem += ev.Size(); + } } } } } else { - for( auto& ev : mem.data ) + if( onlyActive ) { - if( ev.CsAlloc() == 0 ) continue; - if( onlyActive && ev.TimeFree() >= 0 ) continue; - - auto it = pathSum.find( ev.CsAlloc() ); - if( it == pathSum.end() ) + for( auto& ev : mem.data ) { - pathSum.emplace( ev.CsAlloc(), MemPathData { 1, ev.Size() } ); + if( ev.CsAlloc() == 0 ) continue; + if( ev.TimeFree() >= 0 ) continue; + auto it = pathSum.find( ev.CsAlloc() ); + if( it == pathSum.end() ) + { + pathSum.emplace( ev.CsAlloc(), MemPathData { 1, ev.Size() } ); + } + else + { + it->second.cnt++; + it->second.mem += ev.Size(); + } } - else + } + else + { + for( auto& ev : mem.data ) { - it->second.cnt++; - it->second.mem += ev.Size(); + if( ev.CsAlloc() == 0 ) continue; + auto it = pathSum.find( ev.CsAlloc() ); + if( it == pathSum.end() ) + { + pathSum.emplace( ev.CsAlloc(), MemPathData { 1, ev.Size() } ); + } + else + { + it->second.cnt++; + it->second.mem += ev.Size(); + } } } } |