1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Simplify GetNextLockEvent().

This commit is contained in:
Bartosz Taudul 2017-12-09 19:28:12 +01:00
parent b67989ab54
commit 86006e8416

View File

@ -2753,13 +2753,12 @@ enum class LockState
WaitLock // red WaitLock // red
}; };
static Vector<LockEvent*>::iterator GetNextLockEvent( const Vector<LockEvent*>::iterator& it, const Vector<LockEvent*>::iterator& end, LockState state, LockState& nextState, uint64_t threadBit ) static Vector<LockEvent*>::iterator GetNextLockEvent( const Vector<LockEvent*>::iterator& it, const Vector<LockEvent*>::iterator& end, LockState& nextState, uint64_t threadBit )
{ {
nextState = LockState::Nothing;
auto next = it; auto next = it;
next++; next++;
switch( state ) switch( nextState )
{ {
case LockState::Nothing: case LockState::Nothing:
while( next < end ) while( next < end )
@ -2781,7 +2780,6 @@ static Vector<LockEvent*>::iterator GetNextLockEvent( const Vector<LockEvent*>::
} }
break; break;
case LockState::HasLock: case LockState::HasLock:
nextState = LockState::HasLock;
while( next < end ) while( next < end )
{ {
if( (*next)->lockCount == 0 ) if( (*next)->lockCount == 0 )
@ -2805,7 +2803,6 @@ static Vector<LockEvent*>::iterator GetNextLockEvent( const Vector<LockEvent*>::
} }
break; break;
case LockState::HasBlockingLock: case LockState::HasBlockingLock:
nextState = LockState::HasBlockingLock;
while( next < end ) while( next < end )
{ {
if( (*next)->lockCount == 0 ) if( (*next)->lockCount == 0 )
@ -2821,7 +2818,6 @@ static Vector<LockEvent*>::iterator GetNextLockEvent( const Vector<LockEvent*>::
} }
break; break;
case LockState::WaitLock: case LockState::WaitLock:
nextState = LockState::WaitLock;
while( next < end ) while( next < end )
{ {
if( GetThreadBit( (*next)->lockingThread ) == threadBit ) if( GetThreadBit( (*next)->lockingThread ) == threadBit )
@ -2905,7 +2901,7 @@ int View::DrawLocks( uint64_t tid, bool hover, double pxns, const ImVec2& wpos,
{ {
while( vbegin < vend && ( state == LockState::Nothing || ( m_onlyContendedLocks && state == LockState::HasLock ) ) ) while( vbegin < vend && ( state == LockState::Nothing || ( m_onlyContendedLocks && state == LockState::HasLock ) ) )
{ {
vbegin = GetNextLockEvent( vbegin, vend, state, state, threadBit ); vbegin = GetNextLockEvent( vbegin, vend, state, threadBit );
} }
if( vbegin >= vend ) break; if( vbegin >= vend ) break;
@ -2913,7 +2909,7 @@ int View::DrawLocks( uint64_t tid, bool hover, double pxns, const ImVec2& wpos,
drawn = true; drawn = true;
LockState drawState = state; LockState drawState = state;
auto next = GetNextLockEvent( vbegin, vend, state, state, threadBit ); auto next = GetNextLockEvent( vbegin, vend, state, threadBit );
const auto t0 = (*vbegin)->time; const auto t0 = (*vbegin)->time;
int64_t t1 = next == tl.end() ? GetLastTime() : (*next)->time; int64_t t1 = next == tl.end() ? GetLastTime() : (*next)->time;
@ -2929,12 +2925,12 @@ int View::DrawLocks( uint64_t tid, bool hover, double pxns, const ImVec2& wpos,
auto ns = state; auto ns = state;
while( n < vend && ( ns == LockState::Nothing || ( m_onlyContendedLocks && ns == LockState::HasLock ) ) ) while( n < vend && ( ns == LockState::Nothing || ( m_onlyContendedLocks && ns == LockState::HasLock ) ) )
{ {
n = GetNextLockEvent( n, vend, ns, ns, threadBit ); n = GetNextLockEvent( n, vend, ns, threadBit );
} }
if( n >= vend ) break; if( n >= vend ) break;
if( n == next ) if( n == next )
{ {
n = GetNextLockEvent( n, vend, ns, ns, threadBit ); n = GetNextLockEvent( n, vend, ns, threadBit );
} }
drawState = CombineLockState( drawState, state ); drawState = CombineLockState( drawState, state );
condensed++; condensed++;