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:
Steve Checkoway
2006-06-18 00:36:58 +00:00
parent 9547b09cb7
commit 6e6808008e
+7 -8
View File
@@ -57,15 +57,14 @@ void NoteDataUtil::LoadFromSMNoteDataString( NoteData &out, RString sSMNoteData
out.Init();
out.SetNumTracks( iNumTracks );
// strip comments out of sSMNoteData
while( sSMNoteData.find("//") != string::npos )
{
size_t iIndexCommentStart = sSMNoteData.find("//");
size_t iIndexCommentEnd = sSMNoteData.find("\n", iIndexCommentStart);
if( iIndexCommentEnd == string::npos ) // comment doesn't have an end?
sSMNoteData.erase( iIndexCommentStart, 2 );
else
sSMNoteData.erase( iIndexCommentStart, iIndexCommentEnd-iIndexCommentStart );
RString::size_type iIndexCommentStart = 0;
while( (iIndexCommentStart = sSMNoteData.find("//", iIndexCommentStart)) != RString::npos )
{
RString::size_type iIndexCommentEnd = sSMNoteData.find( "\n", iIndexCommentStart );
sSMNoteData.erase( iIndexCommentStart, iIndexCommentEnd - iIndexCommentStart );
}
}
vector<RString> asMeasures;