From f7341141cf5a43afc7919c62eef5c750bd2624e8 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 23 May 2020 14:23:04 +0200 Subject: [PATCH] Cache zone source location source files. --- server/TracyWorker.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index 1068cccc..102d58b4 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -3603,7 +3603,24 @@ void Worker::AddSourceLocation( const QueueSourceLocation& srcloc ) auto it = m_data.sourceLocation.find( ptr ); assert( it != m_data.sourceLocation.end() ); CheckString( srcloc.name ); - CheckString( srcloc.file ); + if( CheckString( srcloc.file ) ) + { + StringRef ref( StringRef::Ptr, srcloc.file ); + assert( m_pendingFileStrings.find( ref ) == m_pendingFileStrings.end() ); + if( srcloc.file != 0 && m_checkedFileStrings.find( ref ) == m_checkedFileStrings.end() ) + { + CacheSource( ref ); + } + } + else + { + StringRef ref( StringRef::Ptr, srcloc.file ); + assert( m_checkedFileStrings.find( ref ) == m_checkedFileStrings.end() ); + if( m_pendingFileStrings.find( ref ) == m_pendingFileStrings.end() ) + { + m_pendingFileStrings.emplace( ref ); + } + } CheckString( srcloc.function ); const uint32_t color = ( srcloc.r << 16 ) | ( srcloc.g << 8 ) | srcloc.b; it->second = SourceLocation { srcloc.name == 0 ? StringRef() : StringRef( StringRef::Ptr, srcloc.name ), StringRef( StringRef::Ptr, srcloc.function ), StringRef( StringRef::Ptr, srcloc.file ), srcloc.line, color }; @@ -3672,6 +3689,14 @@ void Worker::AddString( uint64_t ptr, const char* str, size_t sz ) assert( it != m_data.strings.end() && strcmp( it->second, "???" ) == 0 ); const auto sl = StoreString( str, sz ); it->second = sl.ptr; + + StringRef ref( StringRef::Ptr, ptr ); + auto sit = m_pendingFileStrings.find( ref ); + if( sit != m_pendingFileStrings.end() ) + { + m_pendingFileStrings.erase( sit ); + CacheSource( ref ); + } } void Worker::AddThreadString( uint64_t id, const char* str, size_t sz )