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;

View File

@ -439,7 +439,7 @@ void cUIDsys::GetTitleIDs(std::vector<u64>& _TitleIDs, bool _owned)
}
}
u64 CNANDContentManager::Install_WiiWAD(std::string &fileName)
u64 CNANDContentManager::Install_WiiWAD(const std::string& fileName)
{
if (fileName.find(".wad") == std::string::npos)
return 0;

View File

@ -69,7 +69,7 @@ class CNANDContentManager
{
public:
static CNANDContentManager& Access() { static CNANDContentManager instance; return instance; }
u64 Install_WiiWAD(std::string &fileName);
u64 Install_WiiWAD(const std::string& fileName);
const INANDContentLoader& GetNANDLoader(const std::string& _rName, bool forceReload = false);
const INANDContentLoader& GetNANDLoader(u64 _titleId, bool forceReload = false);

View File

@ -92,7 +92,7 @@ public:
std::string expr;
std::string::iterator it;
Lexer(std::string expr_) : expr(expr_)
Lexer(const std::string& expr_) : expr(expr_)
{
it = expr.begin();
}
@ -568,7 +568,7 @@ Expression::~Expression()
delete node;
}
static ExpressionParseStatus ParseExpressionInner(std::string str, ControlFinder &finder, Expression **expr_out)
static ExpressionParseStatus ParseExpressionInner(const std::string& str, ControlFinder &finder, Expression **expr_out)
{
ExpressionParseStatus status;
Expression *expr;
@ -592,7 +592,7 @@ static ExpressionParseStatus ParseExpressionInner(std::string str, ControlFinder
return EXPRESSION_PARSE_SUCCESS;
}
ExpressionParseStatus ParseExpression(std::string str, ControlFinder &finder, Expression **expr_out)
ExpressionParseStatus ParseExpression(const std::string& str, ControlFinder &finder, Expression **expr_out)
{
// Add compatibility with old simple expressions, which are simple
// barewords control names.

View File

@ -63,7 +63,7 @@ enum ExpressionParseStatus
EXPRESSION_PARSE_NO_DEVICE,
};
ExpressionParseStatus ParseExpression(std::string expr, ControlFinder &finder, Expression **expr_out);
ExpressionParseStatus ParseExpression(const std::string& expr, ControlFinder &finder, Expression **expr_out);
}
}

View File

@ -1908,7 +1908,7 @@ namespace GLExtensions
_GLVersion = 330; // Get all the fun things
}
static void* GetFuncAddress(std::string name, void **func)
static void* GetFuncAddress(const std::string& name, void **func)
{
*func = GLInterface->GetFuncAddress(name);
if (*func == nullptr)

View File

@ -293,7 +293,7 @@ void PostProcessingShaderConfiguration::ReloadShader()
m_current_shader = "";
}
void PostProcessingShaderConfiguration::SetOptionf(std::string option, int index, float value)
void PostProcessingShaderConfiguration::SetOptionf(const std::string& option, int index, float value)
{
auto it = m_options.find(option);
@ -302,7 +302,7 @@ void PostProcessingShaderConfiguration::SetOptionf(std::string option, int index
m_any_options_dirty = true;
}
void PostProcessingShaderConfiguration::SetOptioni(std::string option, int index, s32 value)
void PostProcessingShaderConfiguration::SetOptioni(const std::string& option, int index, s32 value)
{
auto it = m_options.find(option);
@ -311,7 +311,7 @@ void PostProcessingShaderConfiguration::SetOptioni(std::string option, int index
m_any_options_dirty = true;
}
void PostProcessingShaderConfiguration::SetOptionb(std::string option, bool value)
void PostProcessingShaderConfiguration::SetOptionb(const std::string& option, bool value)
{
auto it = m_options.find(option);

View File

@ -68,9 +68,9 @@ public:
const ConfigurationOption& GetOption(const std::string& option) { return m_options[option]; }
// For updating option's values
void SetOptionf(std::string option, int index, float value);
void SetOptioni(std::string option, int index, s32 value);
void SetOptionb(std::string option, bool value);
void SetOptionf(const std::string& option, int index, float value);
void SetOptioni(const std::string& option, int index, s32 value);
void SetOptionb(const std::string& option, bool value);
private:
bool m_any_options_dirty;