GetNumNotesWithGrade is very slow when we have to call it on every
grade type, since we have to search for the given grade; instead, use GetGrades, which returns all grade counts in one pass (fixes grade sort speed regression; 10x speedup)
This commit is contained in:
@@ -160,13 +160,13 @@ void SongUtil::SortSongPointerArrayByGrade( vector<Song*> &arraySongPointers )
|
|||||||
{
|
{
|
||||||
Song *pSong = arraySongPointers[i];
|
Song *pSong = arraySongPointers[i];
|
||||||
|
|
||||||
|
int iCounts[NUM_GRADES];
|
||||||
|
PROFILEMAN->GetMachineProfile()->GetGrades( pSong, GAMESTATE->GetCurrentStyleDef()->m_StepsType, iCounts );
|
||||||
|
|
||||||
CString foo;
|
CString foo;
|
||||||
foo.reserve(256);
|
foo.reserve(256);
|
||||||
for( int g=GRADE_TIER_1; g<=GRADE_NO_DATA; ++g )
|
for( int g=GRADE_TIER_1; g<=GRADE_NO_DATA; ++g )
|
||||||
{
|
AppendOctal( iCounts[g], 3, foo );
|
||||||
int n = pSong->GetNumNotesWithGrade( (Grade)g );
|
|
||||||
AppendOctal( n, 3, foo );
|
|
||||||
}
|
|
||||||
vals.push_back( val(pSong, foo) );
|
vals.push_back( val(pSong, foo) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,12 +276,14 @@ CString SongUtil::GetSectionNameFromSongAndSort( const Song* pSong, SortOrder so
|
|||||||
return "";
|
return "";
|
||||||
case SORT_GRADE:
|
case SORT_GRADE:
|
||||||
{
|
{
|
||||||
|
int iCounts[NUM_GRADES];
|
||||||
|
PROFILEMAN->GetMachineProfile()->GetGrades( pSong, GAMESTATE->GetCurrentStyleDef()->m_StepsType, iCounts );
|
||||||
|
|
||||||
for( int i=GRADE_TIER_1; i<NUM_GRADES; ++i )
|
for( int i=GRADE_TIER_1; i<NUM_GRADES; ++i )
|
||||||
{
|
{
|
||||||
Grade g = (Grade)i;
|
Grade g = (Grade)i;
|
||||||
int iCount = pSong->GetNumNotesWithGrade( g );
|
if( iCounts[i] > 0 )
|
||||||
if( iCount > 0 )
|
return ssprintf( "%4s x %d", GradeToThemedString(g).c_str(), iCounts[i] );
|
||||||
return ssprintf( "%4s x %d", GradeToThemedString(g).c_str(), iCount );
|
|
||||||
}
|
}
|
||||||
return GradeToThemedString( GRADE_NO_DATA );
|
return GradeToThemedString( GRADE_NO_DATA );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user