Collapse separate find zone histogram paths into one.

This commit is contained in:
Bartosz Taudul 2018-09-02 01:31:09 +02:00
parent bb9da36f7e
commit 8152e213f8

View File

@ -4676,13 +4676,9 @@ void View::DrawFindZone()
memset( selBin.get(), 0, sizeof( int64_t ) * numBins );
int64_t selectionTime = 0;
if( m_findZone.highlight.active )
{
const auto s = std::min( m_findZone.highlight.start, m_findZone.highlight.end );
const auto e = std::max( m_findZone.highlight.start, m_findZone.highlight.end );
if( selGroup != m_findZone.Unselected )
{
if( m_findZone.logTime )
{
const auto tMinLog = log10fast( tmin );
@ -4695,11 +4691,11 @@ void View::DrawFindZone()
const auto bin = std::min( numBins - 1, int64_t( ( log10fast( timeSpan ) - tMinLog ) * idt ) );
bins[bin]++;
binTime[bin] += timeSpan;
if( selGroup == GetSelectionTarget( ev, groupBy ) )
if( selGroup != m_findZone.Unselected && selGroup == GetSelectionTarget( ev, groupBy ) )
{
if( cumulateTime ) selBin[bin] += timeSpan; else selBin[bin]++;
}
if( timeSpan >= s && timeSpan <= e ) selectionTime += timeSpan;
if( m_findZone.highlight.active && timeSpan >= s && timeSpan <= e ) selectionTime += timeSpan;
}
}
}
@ -4714,122 +4710,11 @@ void View::DrawFindZone()
const auto bin = std::min( numBins - 1, int64_t( ( timeSpan - tmin ) * idt ) );
bins[bin]++;
binTime[bin] += timeSpan;
if( selGroup == GetSelectionTarget( ev, groupBy ) )
if( selGroup != m_findZone.Unselected && selGroup == GetSelectionTarget( ev, groupBy ) )
{
if( cumulateTime ) selBin[bin] += timeSpan; else selBin[bin]++;
}
if( timeSpan >= s && timeSpan <= e ) selectionTime += timeSpan;
}
}
}
}
else
{
if( m_findZone.logTime )
{
const auto tMinLog = log10fast( tmin );
const auto idt = numBins / ( log10fast( tmax ) - tMinLog );
for( auto& ev : zones )
{
const auto timeSpan = m_worker.GetZoneEndDirect( *ev.zone ) - ev.zone->start;
if( timeSpan != 0 )
{
const auto bin = std::min( numBins - 1, int64_t( ( log10fast( timeSpan ) - tMinLog ) * idt ) );
bins[bin]++;
binTime[bin] += timeSpan;
if( timeSpan >= s && timeSpan <= e ) selectionTime += timeSpan;
}
}
}
else
{
const auto idt = numBins / dt;
for( auto& ev : zones )
{
const auto timeSpan = m_worker.GetZoneEndDirect( *ev.zone ) - ev.zone->start;
if( timeSpan != 0 )
{
const auto bin = std::min( numBins - 1, int64_t( ( timeSpan - tmin ) * idt ) );
bins[bin]++;
binTime[bin] += timeSpan;
if( timeSpan >= s && timeSpan <= e ) selectionTime += timeSpan;
}
}
}
}
}
else
{
if( selGroup != m_findZone.Unselected )
{
if( m_findZone.logTime )
{
const auto tMinLog = log10fast( tmin );
const auto idt = numBins / ( log10fast( tmax ) - tMinLog );
for( auto& ev : zones )
{
const auto timeSpan = m_worker.GetZoneEndDirect( *ev.zone ) - ev.zone->start;
if( timeSpan != 0 )
{
const auto bin = std::min( numBins - 1, int64_t( ( log10fast( timeSpan ) - tMinLog ) * idt ) );
bins[bin]++;
binTime[bin] += timeSpan;
if( selGroup == GetSelectionTarget( ev, groupBy ) )
{
if( cumulateTime ) selBin[bin] += timeSpan; else selBin[bin]++;
}
}
}
}
else
{
const auto idt = numBins / dt;
for( auto& ev : zones )
{
const auto timeSpan = m_worker.GetZoneEndDirect( *ev.zone ) - ev.zone->start;
if( timeSpan != 0 )
{
const auto bin = std::min( numBins - 1, int64_t( ( timeSpan - tmin ) * idt ) );
bins[bin]++;
binTime[bin] += timeSpan;
if( selGroup == GetSelectionTarget( ev, groupBy ) )
{
if( cumulateTime ) selBin[bin] += timeSpan; else selBin[bin]++;
}
}
}
}
}
else
{
if( m_findZone.logTime )
{
const auto tMinLog = log10fast( tmin );
const auto idt = numBins / ( log10fast( tmax ) - tMinLog );
for( auto& ev : zones )
{
const auto timeSpan = m_worker.GetZoneEndDirect( *ev.zone ) - ev.zone->start;
if( timeSpan != 0 )
{
const auto bin = std::min( numBins - 1, int64_t( ( log10fast( timeSpan ) - tMinLog ) * idt ) );
bins[bin]++;
binTime[bin] += timeSpan;
}
}
}
else
{
const auto idt = numBins / dt;
for( auto& ev : zones )
{
const auto timeSpan = m_worker.GetZoneEndDirect( *ev.zone ) - ev.zone->start;
if( timeSpan != 0 )
{
const auto bin = std::min( numBins - 1, int64_t( ( timeSpan - tmin ) * idt ) );
bins[bin]++;
binTime[bin] += timeSpan;
}
}
if( m_findZone.highlight.active && timeSpan >= s && timeSpan <= e ) selectionTime += timeSpan;
}
}
}