[6899] Pass const reference instead of value for some strings in some functions.

Signed-off-by: hunuza <hunuza@gmail.com>
This commit is contained in:
hunuza 2008-12-12 14:16:24 +01:00
parent d386a67d27
commit 0f12997ef1
40 changed files with 108 additions and 108 deletions

View file

@ -30,7 +30,7 @@ char const* localeNames[MAX_LOCALE] = {
"ruRU"
};
LocaleConstant GetLocaleByName(std::string name)
LocaleConstant GetLocaleByName(const std::string& name)
{
for(uint32 i = 0; i < MAX_LOCALE; ++i)
if(name==localeNames[i])

View file

@ -186,7 +186,7 @@ enum LocaleConstant
extern char const* localeNames[MAX_LOCALE];
LocaleConstant GetLocaleByName(std::string name);
LocaleConstant GetLocaleByName(const std::string& name);
// we always use stdlibc++ std::max/std::min, undefine some not C++ standard defines (Win API and some pother platforms)
#ifdef max

View file

@ -128,7 +128,7 @@ DBCStorage <WorldSafeLocsEntry> sWorldSafeLocsStore(WorldSafeLocsEntryfmt);
typedef std::list<std::string> StoreProblemList;
static bool LoadDBC_assert_print(uint32 fsize,uint32 rsize, std::string filename)
static bool LoadDBC_assert_print(uint32 fsize,uint32 rsize, const std::string& filename)
{
sLog.outError("ERROR: Size of '%s' setted by format string (%u) not equal size of C++ structure (%u).",filename.c_str(),fsize,rsize);
@ -137,7 +137,7 @@ static bool LoadDBC_assert_print(uint32 fsize,uint32 rsize, std::string filename
}
template<class T>
inline void LoadDBC(uint32& availableDbcLocales,barGoLink& bar, StoreProblemList& errlist, DBCStorage<T>& storage, std::string dbc_path, std::string filename)
inline void LoadDBC(uint32& availableDbcLocales,barGoLink& bar, StoreProblemList& errlist, DBCStorage<T>& storage, const std::string& dbc_path, const std::string& filename)
{
// compatibility format and C++ structure sizes
assert(DBCFile::GetFormatRecordSize(storage.GetFormat()) == sizeof(T) || LoadDBC_assert_print(DBCFile::GetFormatRecordSize(storage.GetFormat()),sizeof(T),filename));
@ -172,7 +172,7 @@ inline void LoadDBC(uint32& availableDbcLocales,barGoLink& bar, StoreProblemList
}
}
void LoadDBCStores(std::string dataPath)
void LoadDBCStores(const std::string& dataPath)
{
std::string dbcPath = dataPath+"dbc/";

View file

@ -195,7 +195,7 @@ extern DBCStorage <TotemCategoryEntry> sTotemCategoryStore;
//extern DBCStorage <WorldMapAreaEntry> sWorldMapAreaStore; -- use Zone2MapCoordinates and Map2ZoneCoordinates
extern DBCStorage <WorldSafeLocsEntry> sWorldSafeLocsStore;
void LoadDBCStores(std::string dataPath);
void LoadDBCStores(const std::string& dataPath);
// script support functions
MANGOS_DLL_SPEC DBCStorage <SoundEntriesEntry> const* GetSoundEntriesStore();

View file

@ -43,7 +43,7 @@ Log::Log() :
Initialize();
}
void Log::InitColors(std::string str)
void Log::InitColors(const std::string& str)
{
if(str.empty())
{

View file

@ -82,7 +82,7 @@ class Log : public MaNGOS::Singleton<Log, MaNGOS::ClassLevelLockable<Log, ZThrea
}
public:
void Initialize();
void InitColors(std::string init_str);
void InitColors(const std::string& init_str);
void outTitle( const char * str);
void outCommand( uint32 account, const char * str, ...) ATTR_PRINTF(3,4);
void outString(); // any log level

View file

@ -131,13 +131,13 @@ std::string secsToTimeString(uint32 timeInSecs, bool shortText, bool hoursOnly)
return ss.str();
}
uint32 TimeStringToSecs(std::string timestring)
uint32 TimeStringToSecs(const std::string& timestring)
{
uint32 secs = 0;
uint32 buffer = 0;
uint32 multiplier = 0;
for(std::string::iterator itr = timestring.begin(); itr != timestring.end(); itr++ )
for(std::string::const_iterator itr = timestring.begin(); itr != timestring.end(); itr++ )
{
if(isdigit(*itr))
{
@ -193,7 +193,7 @@ bool IsIPAddress(char const* ipaddress)
}
/// create PID file
uint32 CreatePIDFile(std::string filename)
uint32 CreatePIDFile(const std::string& filename)
{
FILE * pid_file = fopen (filename.c_str(), "w" );
if (pid_file == NULL)
@ -271,7 +271,7 @@ bool Utf8toWStr(char const* utf8str, size_t csize, wchar_t* wstr, size_t& wsize)
return true;
}
bool Utf8toWStr(std::string utf8str, std::wstring& wstr)
bool Utf8toWStr(const std::string& utf8str, std::wstring& wstr)
{
try
{
@ -376,7 +376,7 @@ std::wstring GetMainPartOfName(std::wstring wname, uint32 declension)
return wname;
}
bool utf8ToConsole(std::string utf8str, std::string& conStr)
bool utf8ToConsole(const std::string& utf8str, std::string& conStr)
{
#if PLATFORM == PLATFORM_WINDOWS
std::wstring wstr;
@ -393,7 +393,7 @@ bool utf8ToConsole(std::string utf8str, std::string& conStr)
return true;
}
bool consoleToUtf8(std::string conStr,std::string& utf8str)
bool consoleToUtf8(const std::string& conStr,std::string& utf8str)
{
#if PLATFORM == PLATFORM_WINDOWS
std::wstring wstr;
@ -408,7 +408,7 @@ bool consoleToUtf8(std::string conStr,std::string& utf8str)
#endif
}
bool Utf8FitTo(std::string str, std::wstring search)
bool Utf8FitTo(const std::string& str, std::wstring search)
{
std::wstring temp;

View file

@ -31,7 +31,7 @@ Tokens StrSplit(const std::string &src, const std::string &sep);
void stripLineInvisibleChars(std::string &src);
std::string secsToTimeString(uint32 timeInSecs, bool shortText = false, bool hoursOnly = false);
uint32 TimeStringToSecs(std::string timestring);
uint32 TimeStringToSecs(const std::string& timestring);
std::string TimeToTimestampStr(time_t t);
inline uint32 secsToTimeBitFields(time_t secs)
@ -95,10 +95,10 @@ inline void ApplyPercentModFloatVar(float& var, float val, bool apply)
var *= (apply?(100.0f+val)/100.0f : 100.0f / (100.0f+val));
}
bool Utf8toWStr(std::string utf8str, std::wstring& wstr);
bool Utf8toWStr(const std::string& utf8str, std::wstring& wstr);
// in wsize==max size of buffer, out wsize==real string size
bool Utf8toWStr(char const* utf8str, size_t csize, wchar_t* wstr, size_t& wsize);
inline bool Utf8toWStr(std::string utf8str, wchar_t* wstr, size_t& wsize)
inline bool Utf8toWStr(const std::string& utf8str, wchar_t* wstr, size_t& wsize)
{
return Utf8toWStr(utf8str.c_str(), utf8str.size(), wstr, wsize);
}
@ -280,9 +280,9 @@ inline void wstrToLower(std::wstring& str)
std::wstring GetMainPartOfName(std::wstring wname, uint32 declension);
bool utf8ToConsole(std::string utf8str, std::string& conStr);
bool consoleToUtf8(std::string conStr,std::string& utf8str);
bool Utf8FitTo(std::string str, std::wstring search);
bool utf8ToConsole(const std::string& utf8str, std::string& conStr);
bool consoleToUtf8(const std::string& conStr,std::string& utf8str);
bool Utf8FitTo(const std::string& str, std::wstring search);
#if PLATFORM == PLATFORM_WINDOWS
#define UTF8PRINTF(OUT,FRM,RESERR) \
@ -311,6 +311,6 @@ bool Utf8FitTo(std::string str, std::wstring search);
#endif
bool IsIPAddress(char const* ipaddress);
uint32 CreatePIDFile(std::string filename);
uint32 CreatePIDFile(const std::string& filename);
#endif

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "6898"
#define REVISION_NR "6899"
#endif // __REVISION_NR_H__

View file

@ -43,8 +43,8 @@ namespace VMAP
G3D::Array<std::string> iMainFiles;
G3D::Array<std::string> iSingeFiles;
void appendToMain(std::string pStr) { iMainFiles.append(pStr); }
void appendToSingle(std::string pStr) { iSingeFiles.append(pStr); }
void appendToMain(const std::string& pStr) { iMainFiles.append(pStr); }
void appendToSingle(const std::string& pStr) { iSingeFiles.append(pStr); }
size_t size() { return (iMainFiles.size() + iSingeFiles.size()); }
};
@ -113,7 +113,7 @@ namespace VMAP
const NameCollection getFilenamesForCoordinate(unsigned int pMapId, int xPos, int yPos);
static unsigned int getMapIdFromFilename(std::string pName)
static unsigned int getMapIdFromFilename(const std::string& pName)
{
size_t spos;
@ -126,8 +126,8 @@ namespace VMAP
}
const G3D::Array<unsigned int>& getMaps() const { return iMapIds; }
bool isAlreadyProcessedSingleFile(std::string pName) const { return iProcesseSingleFiles.containsKey(pName); }
void addAlreadyProcessedSingleFile(std::string pName) { iProcesseSingleFiles.set(pName,pName); }
bool isAlreadyProcessedSingleFile(const std::string& pName) const { return iProcesseSingleFiles.containsKey(pName); }
void addAlreadyProcessedSingleFile(const std::string& pName) { iProcesseSingleFiles.set(pName,pName); }
inline void addWorldAreaMap(unsigned int pMapId)
{