cleanup (prefer size() over GetLength)

This commit is contained in:
Glenn Maynard
2005-12-21 07:50:14 +00:00
parent 5e2806c5f7
commit 39b07e55b3
11 changed files with 25 additions and 21 deletions
+2 -2
View File
@@ -60,11 +60,11 @@ void MusicList::AddSongsToGroup(const vector<Song*> &Songs)
CString sTitle = Songs[iIndex]->GetDisplayFullTitle();
// TODO: Move this crop threshold into a theme metric or make automatic based on column width
if( sTitle.GetLength() > 40 )
if( sTitle.size() > 40 )
sTitle = sTitle.Left( 37 ) + "...";
CString sTrTitle = Songs[iIndex]->GetTranslitFullTitle();
if( sTrTitle.GetLength() > 40 )
if( sTrTitle.size() > 40 )
sTrTitle = sTrTitle.Left( 37 ) + "...";
/* If the main title isn't complete for this font, and we have a translit,
+1 -1
View File
@@ -20,7 +20,7 @@ void NotesLoader::GetMainAndSubTitlesFromFullTitle( const CString sFullTitle, CS
if( iBeginIndex == -1 )
continue;
sMainTitleOut = sFullTitle.Left( iBeginIndex );
sSubTitleOut = sFullTitle.substr( iBeginIndex+1, sFullTitle.GetLength()-iBeginIndex+1 );
sSubTitleOut = sFullTitle.substr( iBeginIndex+1, sFullTitle.size()-iBeginIndex+1 );
return;
}
sMainTitleOut = sFullTitle;
+1 -1
View File
@@ -302,7 +302,7 @@ bool BMSLoader::LoadFromBMSFile( const CString &sPath, const NameToData_t &mapNa
const CString &sNoteData = it->second;
vector<TapNote> vTapNotes;
for( int i=0; i+1<sNoteData.GetLength(); i+=2 )
for( size_t i=0; i+1<sNoteData.size(); i+=2 )
{
CString sNoteId = sNoteData.substr(i,2);
if( sNoteId != "00" )
+2 -2
View File
@@ -100,7 +100,7 @@ void DWILoader::DWIcharToNoteCol( char c, GameController i, int &col1Out, int &c
* 1/192nds. So, we have to do a check to figure out what it really
* means. If it contains 0s, it's most likely 192nds; otherwise,
* it's most likely a jump. Search for a 0 before the next >: */
bool DWILoader::Is192( const CString &sStepData, int pos )
bool DWILoader::Is192( const CString &sStepData, size_t pos )
{
while( pos < (int) sStepData.size() )
{
@@ -202,7 +202,7 @@ bool DWILoader::LoadFromDWITokens(
double fCurrentBeat = 0;
double fCurrentIncrementer = 1.0/8 * BEATS_PER_MEASURE;
for( int i=0; i<sStepData.GetLength(); )
for( size_t i=0; i<sStepData.size(); )
{
char c = sStepData[i++];
switch( c )
+1 -1
View File
@@ -22,7 +22,7 @@ class DWILoader: public NotesLoader
bool LoadFromDWIFile( CString sPath, Song &out );
static float ParseBrokenDWITimestamp(const CString &arg1, const CString &arg2, const CString &arg3);
static bool Is192( const CString &str, int pos );
static bool Is192( const CString &str, size_t pos );
CString m_sLoadingFile;
public:
+4 -3
View File
@@ -77,10 +77,11 @@ static const OptionColumnEntry g_OptionColumnEntries[] =
int OptionToPreferredColumn( CString sOptionText )
{
/* Speedups always go in column 0. digit ... x */
if(sOptionText.GetLength() > 1 &&
if( sOptionText.size() > 1 &&
isdigit(sOptionText[0]) &&
tolower(sOptionText[sOptionText.GetLength()-1]) == 'x') {
return 0;
tolower(sOptionText[sOptionText.size()-1]) == 'x' )
{
return 0;
}
for( unsigned i=0; i<ARRAYSIZE(g_OptionColumnEntries); i++ )
+6 -4
View File
@@ -91,12 +91,14 @@ void PlayerOptions::GetMods( vector<CString> &AddTo ) const
{
/* -> 1.00 */
CString s = ssprintf( "%2.2f", m_fScrollSpeed );
if( s[s.GetLength()-1] == '0' ) {
if( s[s.size()-1] == '0' )
{
/* -> 1.0 */
s.erase(s.GetLength()-1); // delete last char
if( s[s.GetLength()-1] == '0' ) {
s.erase( s.size()-1 ); // delete last char
if( s[s.size()-1] == '0' )
{
/* -> 1 */
s.erase(s.GetLength()-2); // delete last 2 chars
s.erase( s.size()-2 ); // delete last 2 chars
}
}
AddTo.push_back( s + "x" );
+1 -1
View File
@@ -43,7 +43,7 @@ bool RandomSample::LoadSoundDir( CString sDir, int iMaxToLoad )
* so we'll look for eg. themes\Default\sounds\sDir\*.mp3. Otherwise,
* don't, so we'll look for all of the files starting with sDir,
* eg. themes\Default\sounds\sDir*.mp3. */
if(IsADirectory(sDir) && sDir[sDir.GetLength()-1] != "/" )
if(IsADirectory(sDir) && sDir[sDir.size()-1] != "/" )
sDir += "/";
#else
// make sure there's a slash at the end of this path
+1 -1
View File
@@ -161,7 +161,7 @@ CString Song::GetCacheFilePath() const
* be a cache file. */
const CString &Song::GetSongFilePath() const
{
ASSERT ( m_sSongFileName.GetLength() != 0 );
ASSERT( !m_sSongFileName.empty() );
return m_sSongFileName;
}
+4 -4
View File
@@ -50,8 +50,8 @@ CString SongOptions::GetString() const
if( m_fMusicRate != 1 )
{
CString s = ssprintf( "%2.2f", m_fMusicRate );
if( s[s.GetLength()-1] == '0' )
s.erase(s.GetLength()-1);
if( s[s.size()-1] == '0' )
s.erase( s.size()-1 );
sReturn += s + "xMusic, ";
}
@@ -63,8 +63,8 @@ CString SongOptions::GetString() const
default: ASSERT(0);
}
if( sReturn.GetLength() > 2 )
sReturn.erase( sReturn.GetLength()-2 ); // delete the trailing ", "
if( sReturn.size() > 2 )
sReturn.erase( sReturn.size()-2 ); // delete the trailing ", "
return sReturn;
}
@@ -158,7 +158,8 @@ bool RegistryAccess::SetRegValue( const RString &sKey, const RString &sName, con
bool bSuccess = true;
TCHAR sz[255];
if (sVal.GetLength() > 254) return FALSE;
if( sVal.size() > 254 )
return false;
strcpy( sz, sVal.c_str() );