From 93ab2afccc4297fb712546b1ffb09826afe0fc63 Mon Sep 17 00:00:00 2001 From: Jason Felds Date: Wed, 1 May 2013 22:23:49 -0400 Subject: [PATCH] Good number of loops here. --- src/Song.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/Song.cpp b/src/Song.cpp index 3a8fa01c9f..5ec2f7b788 100644 --- a/src/Song.cpp +++ b/src/Song.cpp @@ -86,8 +86,10 @@ Song::Song() Song::~Song() { - FOREACH( Steps*, m_vpSteps, s ) - SAFE_DELETE( *s ); + for (Steps *s : m_vpSteps) + { + SAFE_DELETE( s ); + } m_vpSteps.clear(); // It's the responsibility of the owner of this Song to make sure @@ -149,8 +151,10 @@ void Song::SetSpecifiedLastSecond(const float f) // Reset to an empty song. void Song::Reset() { - FOREACH( Steps*, m_vpSteps, s ) - SAFE_DELETE( *s ); + for (Steps *s : m_vpSteps) + { + SAFE_DELETE( s ); + } m_vpSteps.clear(); FOREACH_ENUM( StepsType, st ) m_vpStepsByType[st].clear(); @@ -166,7 +170,8 @@ void Song::Reset() void Song::AddBackgroundChange( BackgroundLayer iLayer, BackgroundChange seg ) { // Delete old background change at this start beat, if any. - FOREACH( BackgroundChange, GetBackgroundChanges(iLayer), bgc ) + auto &changes = GetBackgroundChanges(iLayer); + for (vector::iterator bgc = changes.begin(); bgc != changes.end(); ++bgc) { if( bgc->m_fStartBeat == seg.m_fStartBeat ) { @@ -334,11 +339,11 @@ bool Song::LoadFromSongDir( RString sDir ) sCacheFilePath = RString(); } - FOREACH( Steps*, m_vpSteps, s ) + for (Steps *s : m_vpSteps) { /* Compress all Steps. During initial caching, this will remove cached * NoteData; during cached loads, this will just remove cached SMData. */ - (*s)->Compress(); + s->Compress(); } // Load the cached banners, if it's not loaded already. @@ -539,9 +544,9 @@ void Song::TidyUpData( bool fromCache, bool /* duringCache */ ) m_SongTiming.TidyUpData( false ); - FOREACH( Steps *, m_vpSteps, s ) + for (Steps *s : m_vpSteps) { - (*s)->m_Timing.TidyUpData( true ); + s->m_Timing.TidyUpData( true ); } /* Generate these before we autogen notes, so the new notes can inherit @@ -1041,8 +1046,8 @@ bool Song::SaveToSSCFile( RString sPath, bool bSavingCache ) } // Mark these steps saved to disk. - FOREACH( Steps*, vpStepsToSave, s ) - (*s)->SetSavedToDisk( true ); + for (Steps *s : vpStepsToSave) + s->SetSavedToDisk( true ); return true; }