diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 8b07740a..6f57eb7d 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -741,6 +741,9 @@ private: int64_t total[2]; int minBinVal = 1; int compareMode = 0; + bool diffDone = false; + std::vector thisUnique; + std::vector secondUnique; void ResetSelection() { @@ -762,6 +765,9 @@ private: match[i].clear(); selMatch[i] = 0; } + diffDone = false; + thisUnique.clear(); + secondUnique.clear(); } } m_compare; diff --git a/server/TracyView_Compare.cpp b/server/TracyView_Compare.cpp index 7e805516..f003e46b 100644 --- a/server/TracyView_Compare.cpp +++ b/server/TracyView_Compare.cpp @@ -254,6 +254,40 @@ void View::DrawCompare() { ImGui::Separator(); ImGui::BeginChild( "##compare" ); + + if( !m_compare.diffDone ) + { + m_compare.diffDone = true; + + const auto& tfc = m_worker.GetSourceFileCache(); + const auto& ofc = m_compare.second->GetSourceFileCache(); + + if( !tfc.empty() && !ofc.empty() ) + { + for( auto& tv : tfc ) + { + auto it = ofc.find( tv.first ); + if( it == ofc.end() ) + { + m_compare.thisUnique.emplace_back( tv.first ); + } + else if( tv.second.len != it->second.len || memcmp( tv.second.data, it->second.data, tv.second.len ) != 0 ) + { + } + } + for( auto& ov : ofc ) + { + auto it = tfc.find( ov.first ); + if( it == tfc.end() ) + { + m_compare.secondUnique.emplace_back( ov.first ); + } + } + + std::sort( m_compare.thisUnique.begin(), m_compare.thisUnique.end(), []( const auto& lhs, const auto& rhs ) { return strcmp( lhs, rhs ) < 0; } ); + std::sort( m_compare.secondUnique.begin(), m_compare.secondUnique.end(), []( const auto& lhs, const auto& rhs ) { return strcmp( lhs, rhs ) < 0; } ); + } + } } else {