From 10ef60e6ce65a87d2ecfd442630b7d872225df6f Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 5 Jun 2004 07:55:40 +0000 Subject: [PATCH] optimize Song::GetStepsByDifficulty and Song::GetStepsByMeter --- stepmania/src/Song.cpp | 52 ++++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 12 deletions(-) diff --git a/stepmania/src/Song.cpp b/stepmania/src/Song.cpp index c76adf7050..c37e05d7e5 100644 --- a/stepmania/src/Song.cpp +++ b/stepmania/src/Song.cpp @@ -903,22 +903,50 @@ void Song::GetSteps( vector& arrayAddTo, StepsType st, Difficulty dc, in Steps* Song::GetStepsByDifficulty( StepsType st, Difficulty dc, bool bIncludeAutoGen ) const { - vector vNotes; - GetSteps( vNotes, st, dc, -1, -1, "", bIncludeAutoGen, 1 ); - if( vNotes.size() == 0 ) - return NULL; - else - return vNotes[0]; + /* Ignore m_bAutogenSteps for STEPS_TYPE_LIGHTS_CABINET. */ + if( st != STEPS_TYPE_LIGHTS_CABINET && !PREFSMAN->m_bAutogenSteps ) + bIncludeAutoGen = false; + const vector& vpSteps = m_vpSteps; + for( unsigned i=0; im_StepsType != st ) + continue; + if( dc != DIFFICULTY_INVALID && dc != pSteps->GetDifficulty() ) + continue; + if( !bIncludeAutoGen && pSteps->IsAutogen() ) + continue; + + return pSteps; + } + + return NULL; } Steps* Song::GetStepsByMeter( StepsType st, int iMeterLow, int iMeterHigh ) const { - vector vNotes; - GetSteps( vNotes, st, DIFFICULTY_INVALID, iMeterLow, iMeterHigh, "", true, 1 ); - if( vNotes.size() == 0 ) - return NULL; - else - return vNotes[0]; + /* Ignore m_bAutogenSteps for STEPS_TYPE_LIGHTS_CABINET. */ + bool bIncludeAutoGen = (st == STEPS_TYPE_LIGHTS_CABINET || PREFSMAN->m_bAutogenSteps); + + const vector& vpSteps = m_vpSteps; + for( unsigned i=0; im_StepsType != st ) + continue; + if( iMeterLow > pSteps->GetMeter() ) + continue; + if( iMeterHigh < pSteps->GetMeter() ) + continue; + if( !bIncludeAutoGen && pSteps->IsAutogen() ) + continue; + + return pSteps; + } + + return NULL; } Steps* Song::GetStepsByDescription( StepsType st, CString sDescription ) const