Pass strings by const reference where possible

This commit is contained in:
Lioncash
2015-05-28 20:28:48 -04:00
parent 6ff3fcee59
commit ac26f8e79f
21 changed files with 32 additions and 32 deletions

View File

@ -127,15 +127,15 @@ void SetIsFramelimiterTempDisabled(bool disable)
}
std::string GetStateFileName() { return s_state_filename; }
void SetStateFileName(std::string val) { s_state_filename = val; }
void SetStateFileName(const std::string& val) { s_state_filename = val; }
// Display messages and return values
// Formatted stop message
std::string StopMessage(bool bMainThread, std::string Message)
std::string StopMessage(bool main_thread, const std::string& message)
{
return StringFromFormat("Stop [%s %i]\t%s\t%s",
bMainThread ? "Main Thread" : "Video Thread", Common::CurrentThreadId(), MemUsage().c_str(), Message.c_str());
main_thread ? "Main Thread" : "Video Thread", Common::CurrentThreadId(), MemUsage().c_str(), message.c_str());
}
void DisplayMessage(const std::string& message, int time_in_ms)

View File

@ -40,7 +40,7 @@ enum EState
bool Init();
void Stop();
std::string StopMessage(bool, std::string);
std::string StopMessage(bool, const std::string&);
bool IsRunning();
bool IsRunningAndStarted(); // is running and the CPU loop has been entered
@ -59,7 +59,7 @@ void Callback_WiimoteInterruptChannel(int _number, u16 _channelID, const void* _
void DisplayMessage(const std::string& message, int time_in_ms);
std::string GetStateFileName();
void SetStateFileName(std::string val);
void SetStateFileName(const std::string& val);
void SetBlockStart(u32 addr);

View File

@ -329,7 +329,7 @@ bool SCoreStartupParameter::AutoSetup(EBootBS2 _BootBS2)
return true;
}
void SCoreStartupParameter::CheckMemcardPath(std::string& memcardPath, std::string gameRegion, bool isSlotA)
void SCoreStartupParameter::CheckMemcardPath(std::string& memcardPath, const std::string& gameRegion, bool isSlotA)
{
std::string ext("." + gameRegion + ".raw");
if (memcardPath.empty())

View File

@ -254,7 +254,7 @@ struct SCoreStartupParameter
void LoadDefaults();
bool AutoSetup(EBootBS2 _BootBS2);
const std::string &GetUniqueID() const { return m_strUniqueID; }
void CheckMemcardPath(std::string& memcardPath, std::string gameRegion, bool isSlotA);
void CheckMemcardPath(std::string& memcardPath, const std::string& gameRegion, bool isSlotA);
DiscIO::IVolume::ELanguage GetCurrentLanguage(bool wii) const;
IniFile LoadDefaultGameIni() const;

View File

@ -140,7 +140,7 @@ void CEXIIPL::DoState(PointerWrap &p)
p.Do(m_FontsLoaded);
}
void CEXIIPL::LoadFileToIPL(std::string filename, u32 offset)
void CEXIIPL::LoadFileToIPL(const std::string& filename, u32 offset)
{
File::IOFile pStream(filename, "rb");
if (pStream)

View File

@ -68,5 +68,5 @@ private:
bool IsWriteCommand() const { return !!(m_uAddress & (1 << 31)); }
u32 CommandRegion() const { return (m_uAddress & ~(1 << 31)) >> 8; }
void LoadFileToIPL(std::string filename, u32 offset);
void LoadFileToIPL(const std::string& filename, u32 offset);
};

View File

@ -15,7 +15,7 @@
#define SIZE_TO_Mb (1024 * 8 * 16)
#define MC_HDR_SIZE 0xA000
MemoryCard::MemoryCard(std::string filename, int _card_index, u16 sizeMb)
MemoryCard::MemoryCard(const std::string& filename, int _card_index, u16 sizeMb)
: MemoryCardBase(_card_index, sizeMb)
, m_filename(filename)
{

View File

@ -17,7 +17,7 @@ class PointerWrap;
class MemoryCard : public MemoryCardBase
{
public:
MemoryCard(std::string filename, int _card_index, u16 sizeMb = MemCard2043Mb);
MemoryCard(const std::string& filename, int _card_index, u16 sizeMb = MemCard2043Mb);
~MemoryCard();
void FlushThread();
void MakeDirty();

View File

@ -77,7 +77,7 @@ static s32 TranslateErrorCode(s32 native_error, bool isRW)
}
}
s32 WiiSockMan::GetNetErrorCode(s32 ret, std::string caller, bool isRW)
s32 WiiSockMan::GetNetErrorCode(s32 ret, const std::string& caller, bool isRW)
{
#ifdef _WIN32
s32 errorCode = WSAGetLastError();

View File

@ -199,7 +199,7 @@ public:
class WiiSockMan : public ::NonCopyable
{
public:
static s32 GetNetErrorCode(s32 ret, std::string caller, bool isRW);
static s32 GetNetErrorCode(s32 ret, const std::string& caller, bool isRW);
static char* DecodeError(s32 ErrorCode);
static WiiSockMan& GetInstance()

View File

@ -57,7 +57,7 @@ NetPlayClient::~NetPlayClient()
}
// called from ---GUI--- thread
NetPlayClient::NetPlayClient(const std::string& address, const u16 port, NetPlayUI* dialog, const std::string& name, bool traversal, std::string centralServer, u16 centralPort)
NetPlayClient::NetPlayClient(const std::string& address, const u16 port, NetPlayUI* dialog, const std::string& name, bool traversal, const std::string& centralServer, u16 centralPort)
: m_state(Failure)
, m_dialog(dialog)
, m_client(nullptr)

View File

@ -49,7 +49,7 @@ public:
void ThreadFunc();
void SendAsync(sf::Packet* packet);
NetPlayClient(const std::string& address, const u16 port, NetPlayUI* dialog, const std::string& name, bool traversal, std::string centralServer, u16 centralPort);
NetPlayClient(const std::string& address, const u16 port, NetPlayUI* dialog, const std::string& name, bool traversal, const std::string& centralServer, u16 centralPort);
~NetPlayClient();
void GetPlayerList(std::string& list, std::vector<int>& pid_list);

View File

@ -52,7 +52,7 @@ NetPlayServer::~NetPlayServer()
}
// called from ---GUI--- thread
NetPlayServer::NetPlayServer(const u16 port, bool traversal, std::string centralServer, u16 centralPort)
NetPlayServer::NetPlayServer(const u16 port, bool traversal, const std::string& centralServer, u16 centralPort)
: is_connected(false)
, m_is_running(false)
, m_do_loop(false)
@ -717,7 +717,7 @@ std::unordered_set<std::string> NetPlayServer::GetInterfaceSet()
}
// called from ---GUI--- thread
std::string NetPlayServer::GetInterfaceHost(const std::string inter)
std::string NetPlayServer::GetInterfaceHost(const std::string& inter)
{
char buf[16];
sprintf(buf, ":%d", GetPort());

View File

@ -23,7 +23,7 @@ public:
void ThreadFunc();
void SendAsyncToClients(sf::Packet* packet);
NetPlayServer(const u16 port, bool traversal, std::string centralServer, u16 centralPort);
NetPlayServer(const u16 port, bool traversal, const std::string& centralServer, u16 centralPort);
~NetPlayServer();
bool ChangeGame(const std::string& game);
@ -47,7 +47,7 @@ public:
void SetNetPlayUI(NetPlayUI* dialog);
std::unordered_set<std::string> GetInterfaceSet();
std::string GetInterfaceHost(const std::string inter);
std::string GetInterfaceHost(const std::string& inter);
bool is_connected;