From da5d35c3647c4743bde8c7215396863768415952 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Wed, 6 Jun 2018 23:06:00 +0200 Subject: [PATCH] Cache bin containers in find zone. --- server/TracyView.cpp | 17 ++++++++++++----- server/TracyView.hpp | 2 ++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index f4158dd4..295ef43c 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -3425,13 +3425,20 @@ void View::DrawFindZone() const auto numBins = int64_t( w - 4 ); if( numBins > 1 ) { - auto bins = std::make_unique( numBins ); + if( numBins != m_findZone.numBins ) + { + m_findZone.numBins = numBins; + m_findZone.bins = std::make_unique( numBins ); + m_findZone.binTime = std::make_unique( numBins ); + m_findZone.selBin = std::make_unique( numBins ); + } + + const auto& bins = m_findZone.bins; + const auto& binTime = m_findZone.binTime; + const auto& selBin = m_findZone.selBin; + memset( bins.get(), 0, sizeof( int64_t ) * numBins ); - - auto binTime = std::make_unique( numBins ); memset( binTime.get(), 0, sizeof( int64_t ) * numBins ); - - auto selBin = std::make_unique( numBins ); memset( selBin.get(), 0, sizeof( int64_t ) * numBins ); int64_t selBinTime = 0; diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 100b205f..8a19679b 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -211,6 +211,8 @@ private: bool showThreads = true; bool sortByCounts = false; Region highlight; + int64_t numBins = -1; + std::unique_ptr bins, binTime, selBin; void Reset() {