From de92c9ae454503135b043a9e377e25c8ba5b1f1c Mon Sep 17 00:00:00 2001 From: Jason Felds Date: Sun, 28 Apr 2013 23:24:59 -0400 Subject: [PATCH] Lots of loops and a goodie here. I wonder if the last one could be used as a goodie. --- src/Song.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/Song.cpp b/src/Song.cpp index 54b5241986..5ccd4eb557 100644 --- a/src/Song.cpp +++ b/src/Song.cpp @@ -968,9 +968,8 @@ bool Song::SaveToSMFile() FileCopy( sPath, sPath + ".old" ); vector vpStepsToSave; - FOREACH_CONST( Steps*, m_vpSteps, s ) + for (Steps *pSteps : m_vpSteps) { - Steps *pSteps = *s; if( pSteps->IsAutogen() ) continue; // don't write autogen notes @@ -998,9 +997,8 @@ bool Song::SaveToSSCFile( RString sPath, bool bSavingCache ) FileCopy( path, path + ".old" ); vector vpStepsToSave; - FOREACH_CONST( Steps*, m_vpSteps, s ) + for (Steps *pSteps : m_vpSteps) { - Steps *pSteps = *s; if( pSteps->IsAutogen() ) continue; // don't write autogen notes @@ -1192,11 +1190,11 @@ bool Song::IsEasy( StepsType st ) const bool Song::IsTutorial() const { // A Song is considered a Tutorial if it has only Beginner steps. - FOREACH_CONST( Steps*, m_vpSteps, s ) + for (Steps const *s : m_vpSteps) { - if( (*s)->m_StepsType == StepsType_lights_cabinet ) + if( s->m_StepsType == StepsType_lights_cabinet ) continue; // ignore - if( (*s)->GetDifficulty() != Difficulty_Beginner ) + if( s->GetDifficulty() != Difficulty_Beginner ) return false; } @@ -1205,9 +1203,9 @@ bool Song::IsTutorial() const bool Song::HasEdits( StepsType st ) const { - for( unsigned i=0; im_StepsType == st && pSteps->GetDifficulty() == Difficulty_Edit ) { @@ -1216,6 +1214,10 @@ bool Song::HasEdits( StepsType st ) const } return false; +#else + return std::any_of(m_vpSteps.begin(), m_vpSteps.end(), + [&](Steps const *step) { return step->m_StepsType == st && step->GetDifficulty() == Difficulty_Edit; }); +#endif } bool Song::NormallyDisplayed() const @@ -1303,9 +1305,9 @@ vector &Song::GetForegroundChanges() vector Song::GetChangesToVectorString(const vector & changes) const { vector ret; - FOREACH_CONST( BackgroundChange, changes, bgc ) + for (BackgroundChange const &bgc : changes) { - ret.push_back((*bgc).ToString()); + ret.push_back(bgc.ToString()); } return ret; }