do sorting and filtering only once, not once per profile
This commit is contained in:
@@ -1191,38 +1191,44 @@ Course *SongManager::FindCourse( CString sName )
|
|||||||
void SongManager::UpdateBest()
|
void SongManager::UpdateBest()
|
||||||
{
|
{
|
||||||
// update players best
|
// update players best
|
||||||
FOREACH_ProfileSlot( i )
|
vector<Song*> apBestSongs = m_pSongs;
|
||||||
{
|
for ( unsigned j=0; j < apBestSongs.size() ; ++j )
|
||||||
vector<Song*> &Best = m_pBestSongs[i];
|
|
||||||
Best = m_pSongs;
|
|
||||||
|
|
||||||
for ( unsigned j=0; j < Best.size() ; ++j )
|
|
||||||
{
|
{
|
||||||
bool bFiltered = false;
|
bool bFiltered = false;
|
||||||
/* Filter out hidden songs. */
|
/* Filter out hidden songs. */
|
||||||
if( Best[j]->GetDisplayed() != Song::SHOW_ALWAYS )
|
if( apBestSongs[j]->GetDisplayed() != Song::SHOW_ALWAYS )
|
||||||
bFiltered = true;
|
bFiltered = true;
|
||||||
/* Filter out locked songs. */
|
/* Filter out locked songs. */
|
||||||
if( UNLOCKMAN->SongIsLocked(Best[j]) )
|
if( UNLOCKMAN->SongIsLocked(apBestSongs[j]) )
|
||||||
bFiltered = true;
|
bFiltered = true;
|
||||||
if( !bFiltered )
|
if( !bFiltered )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Remove it. */
|
/* Remove it. */
|
||||||
swap( Best[j], Best.back() );
|
swap( apBestSongs[j], apBestSongs.back() );
|
||||||
Best.erase( Best.end()-1 );
|
apBestSongs.erase( apBestSongs.end()-1 );
|
||||||
--j;
|
--j;
|
||||||
}
|
}
|
||||||
|
|
||||||
SongUtil::SortSongPointerArrayByTitle( m_pBestSongs[i] );
|
SongUtil::SortSongPointerArrayByTitle( apBestSongs );
|
||||||
|
|
||||||
|
vector<Course*> apBestCourses[NUM_CourseType];
|
||||||
|
FOREACH_CourseType( ct )
|
||||||
|
{
|
||||||
|
GetCourses( ct, apBestCourses[ct], PREFSMAN->m_bAutogenGroupCourses );
|
||||||
|
CourseUtil::SortCoursePointerArrayByTitle( apBestCourses[ct] );
|
||||||
|
}
|
||||||
|
|
||||||
|
FOREACH_ProfileSlot( i )
|
||||||
|
{
|
||||||
|
m_pBestSongs[i] = apBestSongs;
|
||||||
|
|
||||||
SongUtil::SortSongPointerArrayByNumPlays( m_pBestSongs[i], i, true );
|
SongUtil::SortSongPointerArrayByNumPlays( m_pBestSongs[i], i, true );
|
||||||
|
|
||||||
FOREACH_CourseType( ct )
|
FOREACH_CourseType( ct )
|
||||||
{
|
{
|
||||||
vector<Course*> &vpCourses = m_pBestCourses[i][ct];
|
vector<Course*> &vpCourses = m_pBestCourses[i][ct];
|
||||||
vpCourses.clear();
|
vpCourses = apBestCourses[ct];
|
||||||
GetCourses( ct, vpCourses, PREFSMAN->m_bAutogenGroupCourses );
|
|
||||||
CourseUtil::SortCoursePointerArrayByTitle( vpCourses );
|
|
||||||
CourseUtil::SortCoursePointerArrayByNumPlays( vpCourses, i, true );
|
CourseUtil::SortCoursePointerArrayByNumPlays( vpCourses, i, true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user