Display sample percentage columns only if there's data.

This commit is contained in:
Bartosz Taudul 2020-04-24 00:49:38 +02:00
parent 0ff87d8f40
commit 9a77a59cb2

View File

@ -460,6 +460,21 @@ void SourceView::RenderSymbolView( const Worker& worker, const View& view )
}
pdqsort_branchless( symInline.begin(), symInline.end(), []( const auto& l, const auto& r ) { return l.second == r.second ? l.first < r.first : l.second > r.second; } );
if( totalSamples == 0 )
{
ImGui::Columns( 2 );
static bool widthSet = false;
if( !widthSet )
{
widthSet = true;
const auto w = ImGui::GetWindowWidth();
const auto c1 = ImGui::CalcTextSize( "0xeeeeeeeeeeeeee" ).x;
ImGui::SetColumnWidth( 0, w - c1 );
ImGui::SetColumnWidth( 1, c1 );
}
}
else
{
ImGui::Columns( 3 );
static bool widthSet = false;
if( !widthSet )
@ -472,7 +487,10 @@ void SourceView::RenderSymbolView( const Worker& worker, const View& view )
ImGui::SetColumnWidth( 1, w - c0 - c2 );
ImGui::SetColumnWidth( 2, c2 );
}
}
for( auto& v : symInline )
{
if( totalSamples != 0 )
{
if( v.second != 0 )
{
@ -487,6 +505,7 @@ void SourceView::RenderSymbolView( const Worker& worker, const View& view )
}
}
ImGui::NextColumn();
}
auto isym = worker.GetSymbolData( v.first );
assert( isym );
ImGui::PushID( v.first );
@ -724,6 +743,8 @@ void SourceView::RenderSymbolSourceView( uint32_t iptotal, unordered_flat_map<ui
for( auto& v : fileCounts ) fileCountsVec.emplace_back( v.first, v.second );
pdqsort_branchless( fileCountsVec.begin(), fileCountsVec.end(), [&worker] (const auto& l, const auto& r ) { return l.second == r.second ? strcmp( worker.GetString( l.first ), worker.GetString( r.first ) ) < 0 : l.second > r.second; } );
if( totalSamples != 0 )
{
ImGui::Columns( 2 );
static bool widthSet = false;
if( !widthSet )
@ -734,7 +755,10 @@ void SourceView::RenderSymbolSourceView( uint32_t iptotal, unordered_flat_map<ui
ImGui::SetColumnWidth( 0, c0 );
ImGui::SetColumnWidth( 1, w - c0 );
}
}
for( auto& v : fileCountsVec )
{
if( totalSamples != 0 )
{
auto fit = fileCounts.find( v.first );
assert( fit != fileCounts.end() );
@ -751,6 +775,7 @@ void SourceView::RenderSymbolSourceView( uint32_t iptotal, unordered_flat_map<ui
}
}
ImGui::NextColumn();
}
const auto color = GetHsvColor( v.first, 0 );
SmallColorBox( color );
ImGui::SameLine();
@ -779,9 +804,9 @@ void SourceView::RenderSymbolSourceView( uint32_t iptotal, unordered_flat_map<ui
{
TextDisabledUnformatted( fstr );
}
ImGui::NextColumn();
if( totalSamples != 0 ) ImGui::NextColumn();
}
ImGui::EndColumns();
if( totalSamples != 0 ) ImGui::EndColumns();
}
ImGui::EndCombo();
}