From 5fa72a086f9b3e2574fb1627be1f9a4e0b9ca277 Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Tue, 8 Jan 2013 20:15:50 -0800 Subject: [PATCH] Clean up some miscellaneous non-optimal string uses --- Sources/Plasma/CoreLib/plString.h | 14 +++++--------- .../PubUtilLib/plAudioCore/plSoundBuffer.cpp | 2 +- .../Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp | 2 +- .../Plasma/PubUtilLib/plContainer/plConfigInfo.cpp | 2 +- .../PubUtilLib/plNetClientComm/plNetClientComm.cpp | 2 +- .../Plasma/PubUtilLib/plPipeline/plDXPipeline.cpp | 2 +- .../Plasma/PubUtilLib/plPipeline/plDXPipeline.h | 2 +- Sources/Plasma/PubUtilLib/plSDL/plSDLParser.cpp | 2 +- .../Plasma/PubUtilLib/plSDL/plStateVariable.cpp | 8 ++++---- .../Plasma/PubUtilLib/plStatusLog/plStatusLog.cpp | 7 +++---- .../PubUtilLib/plVault/plVaultNodeAccess.cpp | 2 +- 11 files changed, 20 insertions(+), 25 deletions(-) diff --git a/Sources/Plasma/CoreLib/plString.h b/Sources/Plasma/CoreLib/plString.h index 8d8d8d08..8aa8e0c5 100644 --- a/Sources/Plasma/CoreLib/plString.h +++ b/Sources/Plasma/CoreLib/plString.h @@ -658,15 +658,11 @@ size_t ustrlen(const UniChar *ustr, size_t max = plString::kSizeAuto); #if HS_BUILD_FOR_WIN32 -# define PATH_SEPARATOR '\\' -# define WPATH_SEPARATOR L'\\' -# define PATH_SEPARATOR_STR "\\" -# define WPATH_SEPARATOR_STR L"\\" +# define PATH_SEPARATOR '\\' +# define PATH_SEPARATOR_STR "\\" #else -# define PATH_SEPARATOR '/' -# define WPATH_SEPARATOR L'/' -# define PATH_SEPARATOR_STR "/" -# define WPATH_SEPARATOR_STR L"/" +# define PATH_SEPARATOR '/' +# define PATH_SEPARATOR_STR "/" #endif /* plFileName - custom extension of plString for manipulating filenames */ @@ -687,7 +683,7 @@ public: static plFileName Join(const plFileName &base, const plFileName &path); - // VS doesn't do variadic templates, and we don't want to use const char * + // TODO: Make this more efficient static plFileName Join(const plFileName &base, const plFileName &path, const plFileName& path2) { return Join(Join(base, path), path2); } diff --git a/Sources/Plasma/PubUtilLib/plAudioCore/plSoundBuffer.cpp b/Sources/Plasma/PubUtilLib/plAudioCore/plSoundBuffer.cpp index 6b37058d..9bc4c3b6 100644 --- a/Sources/Plasma/PubUtilLib/plAudioCore/plSoundBuffer.cpp +++ b/Sources/Plasma/PubUtilLib/plAudioCore/plSoundBuffer.cpp @@ -275,7 +275,7 @@ void plSoundBuffer::Write( hsStream *s, hsResMgr *mgr ) s->WriteSafeString( fFileName ); } else - s->WriteSafeString( nil ); + s->WriteSafeString( "" ); s->WriteLE( fHeader.fFormatTag ); s->WriteLE( fHeader.fNumChannels ); diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp index f449d274..43472589 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp @@ -1735,7 +1735,7 @@ void plArmatureMod::Write(hsStream *stream, hsResMgr *mgr) stream->WriteLEFloat(fPhysHeight); stream->WriteLEFloat(fPhysWidth); - stream->WriteSafeString(fAnimationPrefix.c_str()); + stream->WriteSafeString(fAnimationPrefix); stream->WriteSafeString(fBodyAgeName.c_str()); stream->WriteSafeString(fBodyFootstepSoundPage.c_str()); } diff --git a/Sources/Plasma/PubUtilLib/plContainer/plConfigInfo.cpp b/Sources/Plasma/PubUtilLib/plContainer/plConfigInfo.cpp index b7097eb0..bb2137bd 100644 --- a/Sources/Plasma/PubUtilLib/plContainer/plConfigInfo.cpp +++ b/Sources/Plasma/PubUtilLib/plContainer/plConfigInfo.cpp @@ -1116,7 +1116,7 @@ bool plWWWAuthenticateConfigSource::ReadInto(plConfigInfo & configInfo, KAddValu end = i; plString buf = fAuth.Substr(begin, end-begin); - if(!ReadString(buf.c_str())) + if (!ReadString(buf)) { // TODO log warning here } diff --git a/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp b/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp index 1e70ac2b..e522275a 100644 --- a/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp @@ -601,7 +601,7 @@ static void INetCliAuthAgeRequestCallback ( LogMsg( kLogPerf, - L"Connecting to game server %s, ageInstId %s", + L"Connecting to game server %S, ageInstId %S", gameAddrStr.c_str(), ageInstIdStr.c_str() ); diff --git a/Sources/Plasma/PubUtilLib/plPipeline/plDXPipeline.cpp b/Sources/Plasma/PubUtilLib/plPipeline/plDXPipeline.cpp index a938bac1..02435f9c 100644 --- a/Sources/Plasma/PubUtilLib/plPipeline/plDXPipeline.cpp +++ b/Sources/Plasma/PubUtilLib/plPipeline/plDXPipeline.cpp @@ -472,7 +472,7 @@ void D3DSURF_MEMDEL(IDirect3DCubeTexture9* cTex) {} #endif // PLASMA_EXTERNAL_RELEASE #ifndef PLASMA_EXTERNAL_RELEASE -void plDXPipeline::ProfilePoolMem(D3DPOOL poolType, uint32_t size, bool add, char *id) +void plDXPipeline::ProfilePoolMem(D3DPOOL poolType, uint32_t size, bool add, const char *id) { switch( poolType ) { diff --git a/Sources/Plasma/PubUtilLib/plPipeline/plDXPipeline.h b/Sources/Plasma/PubUtilLib/plPipeline/plDXPipeline.h index 75aa9347..99713f8f 100644 --- a/Sources/Plasma/PubUtilLib/plPipeline/plDXPipeline.h +++ b/Sources/Plasma/PubUtilLib/plPipeline/plDXPipeline.h @@ -709,7 +709,7 @@ public: static void AllocManagedVertex(uint32_t sz) { fVtxManaged += sz; } #ifndef PLASMA_EXTERNAL_RELEASE - static void ProfilePoolMem(D3DPOOL poolType, uint32_t size, bool add, char *id); + static void ProfilePoolMem(D3DPOOL poolType, uint32_t size, bool add, const char *id); #endif // PLASMA_EXTERNAL_RELEASE // From a D3DFORMAT enumeration, return the bit depth associated with it. diff --git a/Sources/Plasma/PubUtilLib/plSDL/plSDLParser.cpp b/Sources/Plasma/PubUtilLib/plSDL/plSDLParser.cpp index a3ad5f61..7b0a9a0e 100644 --- a/Sources/Plasma/PubUtilLib/plSDL/plSDLParser.cpp +++ b/Sources/Plasma/PubUtilLib/plSDL/plSDLParser.cpp @@ -310,7 +310,7 @@ bool plSDLParser::IParseVarDesc(const char* fileName, hsStream* stream, char tok } } - DebugMsg((char*)dbgStr.c_str()); + DebugMsg(dbgStr.c_str()); return skipNext; } diff --git a/Sources/Plasma/PubUtilLib/plSDL/plStateVariable.cpp b/Sources/Plasma/PubUtilLib/plSDL/plStateVariable.cpp index ddaa182e..2dffb00d 100644 --- a/Sources/Plasma/PubUtilLib/plSDL/plStateVariable.cpp +++ b/Sources/Plasma/PubUtilLib/plSDL/plStateVariable.cpp @@ -116,7 +116,7 @@ void plStateVarNotificationInfo::Write(hsStream* s, uint32_t writeOptions) const { uint8_t saveFlags=0; // unused s->WriteLE(saveFlags); - s->WriteSafeString(fHintString.c_str()); + s->WriteSafeString(fHintString); } ///////////////////////////////////////////////////// @@ -2325,7 +2325,7 @@ void plSimpleStateVariable::DumpToStream(hsStream* stream, bool dirtyOnly, int l plString logMsg = plString::Format( "%sSimpleVar, name:%s[%d]", pad.c_str(), GetName().c_str(), GetCount()); if (GetCount()>1) { - stream->WriteString(logMsg.c_str()); // it's going to be a long msg, so print it on its own line + stream->WriteString(logMsg); // it's going to be a long msg, so print it on its own line logMsg = ""; } @@ -2348,7 +2348,7 @@ void plSimpleStateVariable::DumpToStream(hsStream* stream, bool dirtyOnly, int l if ( !dirtyOnly ) logMsg += plString::Format( " dirty:%d", IsDirty() ); - stream->WriteString(logMsg.c_str()); + stream->WriteString(logMsg); logMsg = ""; } } @@ -2704,7 +2704,7 @@ void plSDStateVariable::DumpToStream(hsStream* stream, bool dirtyOnly, int level int cnt = dirtyOnly ? GetDirtyCount() : GetUsedCount(); stream->WriteString(plString::Format( "%sSDVar, name:%s dirtyOnly:%d count:%d", - pad.c_str(), GetName().c_str(), dirtyOnly, cnt).c_str()); + pad.c_str(), GetName().c_str(), dirtyOnly, cnt)); for(i=0;i= 1) - needsSeparator = (base[baseLen - 1] != WPATH_SEPARATOR); + needsSeparator = (base[baseLen - 1] != PATH_SEPARATOR); if (needsSeparator) { if ((baseLen + 1 + 1) >= maxLen) return; // abort, buffer isn't big enough - base[baseLen] = WPATH_SEPARATOR; + base[baseLen] = PATH_SEPARATOR; ++baseLen; base[baseLen] = '\0'; } @@ -533,12 +533,11 @@ void plStatusLog::IFini( void ) delete [] fColors; } - void plStatusLog::IParseFileName(wchar_t* file, size_t fnsize, wchar_t* fileNoExt, wchar_t** ext) const { const wchar_t *base = plStatusLogMgr::IGetBasePath(); if( wcslen( base ) != nil ) - hsSnwprintf( file, fnsize, L"%s%s%s", base, WPATH_SEPARATOR_STR, fFilename.c_str() ); + hsSnwprintf( file, fnsize, L"%s%S%s", base, PATH_SEPARATOR_STR, fFilename.c_str() ); else wcscpy( file, fFilename.c_str() ); diff --git a/Sources/Plasma/PubUtilLib/plVault/plVaultNodeAccess.cpp b/Sources/Plasma/PubUtilLib/plVault/plVaultNodeAccess.cpp index 2fccccea..f9529765 100644 --- a/Sources/Plasma/PubUtilLib/plVault/plVaultNodeAccess.cpp +++ b/Sources/Plasma/PubUtilLib/plVault/plVaultNodeAccess.cpp @@ -455,7 +455,7 @@ void VaultAgeLinkNode::AddSpawnPoint (const plSpawnPointInfo & point) { plSpawnPointVec points; GetSpawnPoints( &points ); - if ( std::find_if( points.begin(), points.end(), MatchesSpawnPointTitle( point.fTitle.c_str() ) )!=points.end() ) + if ( std::find_if( points.begin(), points.end(), MatchesSpawnPointTitle( point.fTitle ) )!=points.end() ) return; // only check to see if the titles are the same...