From c689a494da256e68e86fa4ec8f29a89fd54508c3 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Wed, 6 Feb 2019 13:46:50 +0100 Subject: [PATCH] Move call stack paths calculation to a separate function. --- server/TracyView.cpp | 15 +++++++-------- server/TracyView.hpp | 7 +++++++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index e685f38f..0b8f3e96 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -7652,15 +7652,8 @@ static tracy_force_inline CallstackFrameTree* GetFrameTreeItem( std::vector View::GetCallstackFrameTree( const MemData& mem ) const +flat_hash_map> View::GetCallstackPaths( const MemData& mem ) const { - struct PathData - { - uint32_t cnt; - uint64_t mem; - }; - - std::vector root; flat_hash_map> pathSum; pathSum.reserve( m_worker.GetCallstackPayloadCount() ); @@ -7682,7 +7675,13 @@ std::vector View::GetCallstackFrameTree( const MemData& mem it->second.mem += ev.size; } } + return pathSum; +} +std::vector View::GetCallstackFrameTree( const MemData& mem ) const +{ + std::vector root; + auto pathSum = GetCallstackPaths( mem ); for( auto& path : pathSum ) { auto& cs = m_worker.GetCallstack( path.first ); diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 9b5290bf..c65e48eb 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -72,6 +72,12 @@ private: enum { InvalidId = 0xFFFFFFFF }; + struct PathData + { + uint32_t cnt; + uint64_t mem; + }; + void InitTextEditor(); const char* ShortenNamespace( const char* name ) const; @@ -113,6 +119,7 @@ private: template void ListMemData( T ptr, T end, std::function DrawAddress, const char* id = nullptr ); + flat_hash_map> GetCallstackPaths( const MemData& mem ) const; std::vector GetCallstackFrameTree( const MemData& mem ) const; void DrawFrameTreeLevel( std::vector& tree, int& idx );