Simplify. (This changes it from a cubic time operation to a quadratic. Also handles the case where a comment begins on the last line and that line isn't terminated with a newline.)
This commit is contained in:
@@ -57,15 +57,14 @@ void NoteDataUtil::LoadFromSMNoteDataString( NoteData &out, RString sSMNoteData
|
|||||||
out.Init();
|
out.Init();
|
||||||
out.SetNumTracks( iNumTracks );
|
out.SetNumTracks( iNumTracks );
|
||||||
|
|
||||||
// strip comments out of sSMNoteData
|
|
||||||
while( sSMNoteData.find("//") != string::npos )
|
|
||||||
{
|
{
|
||||||
size_t iIndexCommentStart = sSMNoteData.find("//");
|
RString::size_type iIndexCommentStart = 0;
|
||||||
size_t iIndexCommentEnd = sSMNoteData.find("\n", iIndexCommentStart);
|
|
||||||
if( iIndexCommentEnd == string::npos ) // comment doesn't have an end?
|
while( (iIndexCommentStart = sSMNoteData.find("//", iIndexCommentStart)) != RString::npos )
|
||||||
sSMNoteData.erase( iIndexCommentStart, 2 );
|
{
|
||||||
else
|
RString::size_type iIndexCommentEnd = sSMNoteData.find( "\n", iIndexCommentStart );
|
||||||
sSMNoteData.erase( iIndexCommentStart, iIndexCommentEnd-iIndexCommentStart );
|
sSMNoteData.erase( iIndexCommentStart, iIndexCommentEnd - iIndexCommentStart );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<RString> asMeasures;
|
vector<RString> asMeasures;
|
||||||
|
|||||||
Reference in New Issue
Block a user