Optimize. The Unset() call was actually rather expensive. This speeds up SSMusic by a few frames per second for me in optimized builds.

This commit is contained in:
Steve Checkoway
2009-03-26 11:30:45 +00:00
parent 868b7346bc
commit 95645cdafb
+12 -25
View File
@@ -247,31 +247,20 @@ void DifficultyList::PositionItems()
void DifficultyList::SetFromGameState() void DifficultyList::SetFromGameState()
{ {
const Song *pSong = GAMESTATE->m_pCurSong; const Song *pSong = GAMESTATE->m_pCurSong;
unsigned i = 0;
for( int m = 0; m < MAX_METERS; ++m )
{
m_Lines[m].m_Meter.Unset();
}
m_Rows.clear();
if( pSong == NULL ) if( pSong == NULL )
{ {
// FIXME: This clamps to between the min and the max difficulty, but // FIXME: This clamps to between the min and the max difficulty, but
// it really should round to the nearest difficulty that's in // it really should round to the nearest difficulty that's in
// DIFFICULTIES_TO_SHOW. // DIFFICULTIES_TO_SHOW.
unsigned i=0; const vector<Difficulty>& difficulties = CommonMetrics::DIFFICULTIES_TO_SHOW.GetValue();
FOREACH_CONST( Difficulty, CommonMetrics::DIFFICULTIES_TO_SHOW.GetValue(), d ) m_Rows.resize( difficulties.size() );
FOREACH_CONST( Difficulty, difficulties, d )
{ {
m_Rows.resize( m_Rows.size()+1 ); m_Rows[i].m_dc = *d;
Row &row = m_Rows.back();
row.m_dc = *d;
m_Lines[i].m_Meter.SetFromStepsTypeAndMeterAndDifficulty( StepsType_Invalid, 0, *d ); m_Lines[i].m_Meter.SetFromStepsTypeAndMeterAndDifficulty( StepsType_Invalid, 0, *d );
++i;
i++;
} }
} }
else else
@@ -281,17 +270,15 @@ void DifficultyList::SetFromGameState()
/* Should match the sort in ScreenSelectMusic::AfterMusicChange. */ /* Should match the sort in ScreenSelectMusic::AfterMusicChange. */
m_Rows.resize( vpSteps.size() ); m_Rows.resize( vpSteps.size() );
for( unsigned i = 0; i < vpSteps.size(); ++i ) FOREACH_CONST( Steps*, vpSteps, s )
{ {
Row &row = m_Rows[i]; m_Rows[i].m_Steps = *s;
m_Lines[i].m_Meter.SetFromSteps( *s );
row.m_Steps = vpSteps[i]; ++i;
m_Lines[i].m_Meter.SetFromSteps( m_Rows[i].m_Steps );
row.m_dc = row.m_Steps->GetDifficulty();
} }
} }
while( i < MAX_METERS )
m_Lines[i++].m_Meter.Unset();
UpdatePositions(); UpdatePositions();
PositionItems(); PositionItems();