diff --git a/Common/Data/Text/I18n.cpp b/Common/Data/Text/I18n.cpp index 0ede4c516d..00771fe119 100644 --- a/Common/Data/Text/I18n.cpp +++ b/Common/Data/Text/I18n.cpp @@ -39,7 +39,7 @@ const char *I18NCategory::T(const char *key, const char *def) { if (def) missedKeyLog_[key] = def; else - missedKeyLog_[key] = modifiedKey.c_str(); + missedKeyLog_[key] = modifiedKey; // INFO_LOG(SYSTEM, "Missed translation key in %s: %s", name_.c_str(), key); return def ? def : key; } diff --git a/Common/File/Path.cpp b/Common/File/Path.cpp index dd01ac26a7..39a31e164e 100644 --- a/Common/File/Path.cpp +++ b/Common/File/Path.cpp @@ -271,7 +271,7 @@ bool Path::CanNavigateUp() const { if (type_ == PathType::CONTENT_URI) { return AndroidContentURI(path_).CanNavigateUp(); } - if (path_ == "/" || path_ == "") { + if (path_ == "/" || path_.empty()) { return false; } if (type_ == PathType::HTTP) { diff --git a/Common/GPU/OpenGL/thin3d_gl.cpp b/Common/GPU/OpenGL/thin3d_gl.cpp index 02decfe05c..3ecd1695c6 100644 --- a/Common/GPU/OpenGL/thin3d_gl.cpp +++ b/Common/GPU/OpenGL/thin3d_gl.cpp @@ -1203,6 +1203,7 @@ bool OpenGLPipeline::LinkShaders() { } std::vector semantics; + semantics.reserve(8); // Bind all the common vertex data points. Mismatching ones will be ignored. semantics.push_back({ SEM_POSITION, "Position" }); semantics.push_back({ SEM_COLOR0, "Color0" }); diff --git a/Core/Debugger/WebSocket/WebSocketUtils.cpp b/Core/Debugger/WebSocket/WebSocketUtils.cpp index 8d6be87b9e..be1a1371a9 100644 --- a/Core/Debugger/WebSocket/WebSocketUtils.cpp +++ b/Core/Debugger/WebSocket/WebSocketUtils.cpp @@ -216,7 +216,7 @@ bool DebuggerRequest::ParamBool(const char *name, bool *out, DebuggerParamType t *out = true; return true; } - if (s == "0" || s == "false" || (s == "" && allowLoose)) { + if (s == "0" || s == "false" || (s.empty() && allowLoose)) { *out = false; return true; } diff --git a/Core/Dialog/PSPNetconfDialog.cpp b/Core/Dialog/PSPNetconfDialog.cpp index 1e0535f301..079ff28358 100644 --- a/Core/Dialog/PSPNetconfDialog.cpp +++ b/Core/Dialog/PSPNetconfDialog.cpp @@ -194,21 +194,21 @@ void PSPNetconfDialog::DisplayMessage(std::string text1, std::string text2a, std PPGeScissor(0, (int)(centerY - h2 - 2), 480, (int)(centerY + h2 + 2)); PPGeDrawTextWrapped(text1.c_str(), 240.0f, centerY - h2 - scrollPos_, WRAP_WIDTH, 0, messageStyle); - if (text2a != "") { - if (text2b != "") + if (!text2a.empty()) { + if (!text2b.empty()) PPGeDrawTextWrapped(text2a.c_str(), 240.0f - 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + marginTop, WRAP_WIDTH, 0, messageStyleRight); else PPGeDrawTextWrapped(text2a.c_str(), 240.0f, centerY - h2 - scrollPos_ + totalHeight1 + marginTop, WRAP_WIDTH, 0, messageStyle); } - if (text2b != "") + if (!text2b.empty()) PPGeDrawTextWrapped(text2b.c_str(), 240.0f + 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + marginTop, WRAP_WIDTH, 0, messageStyleLeft); - if (text3a != "") { - if (text3b != "") + if (!text3a.empty()) { + if (!text3b.empty()) PPGeDrawTextWrapped(text3a.c_str(), 240.0f - 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + totalHeight2 + marginTop, WRAP_WIDTH, 0, messageStyleRight); else PPGeDrawTextWrapped(text3a.c_str(), 240.0f, centerY - h2 - scrollPos_ + totalHeight1 + totalHeight2 + marginTop, WRAP_WIDTH, 0, messageStyle); } - if (text3b != "") + if (!text3b.empty()) PPGeDrawTextWrapped(text3b.c_str(), 240.0f + 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + totalHeight2 + marginTop, WRAP_WIDTH, 0, messageStyleLeft); PPGeScissorReset(); diff --git a/Core/Dialog/PSPNpSigninDialog.cpp b/Core/Dialog/PSPNpSigninDialog.cpp index 3c015046db..48245c2008 100644 --- a/Core/Dialog/PSPNpSigninDialog.cpp +++ b/Core/Dialog/PSPNpSigninDialog.cpp @@ -191,21 +191,21 @@ void PSPNpSigninDialog::DisplayMessage(std::string text1, std::string text2a, st PPGeScissor(0, (int)(centerY - h2 - 2), 480, (int)(centerY + h2 + 2)); PPGeDrawTextWrapped(text1.c_str(), 240.0f, centerY - h2 - scrollPos_, WRAP_WIDTH, 0, messageStyle); - if (text2a != "") { - if (text2b != "") + if (!text2a.empty()) { + if (!text2b.empty()) PPGeDrawTextWrapped(text2a.c_str(), 240.0f - 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + marginTop, WRAP_WIDTH, 0, messageStyleRight); else PPGeDrawTextWrapped(text2a.c_str(), 240.0f, centerY - h2 - scrollPos_ + totalHeight1 + marginTop, WRAP_WIDTH, 0, messageStyle); } - if (text2b != "") + if (!text2b.empty()) PPGeDrawTextWrapped(text2b.c_str(), 240.0f + 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + marginTop, WRAP_WIDTH, 0, messageStyleLeft); - if (text3a != "") { - if (text3b != "") + if (!text3a.empty()) { + if (!text3b.empty()) PPGeDrawTextWrapped(text3a.c_str(), 240.0f - 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + totalHeight2 + marginTop, WRAP_WIDTH, 0, messageStyleRight); else PPGeDrawTextWrapped(text3a.c_str(), 240.0f, centerY - h2 - scrollPos_ + totalHeight1 + totalHeight2 + marginTop, WRAP_WIDTH, 0, messageStyle); } - if (text3b != "") + if (!text3b.empty()) PPGeDrawTextWrapped(text3b.c_str(), 240.0f + 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + totalHeight2 + marginTop, WRAP_WIDTH, 0, messageStyleLeft); PPGeScissorReset(); diff --git a/Core/Dialog/SavedataParam.cpp b/Core/Dialog/SavedataParam.cpp index a4f437d40c..67ef655ccf 100644 --- a/Core/Dialog/SavedataParam.cpp +++ b/Core/Dialog/SavedataParam.cpp @@ -353,11 +353,11 @@ int SavedataParam::DeleteData(SceUtilitySavedataParam* param) { if (!pspFileSystem.GetFileInfo(sfoPath).exists) return SCE_UTILITY_SAVEDATA_ERROR_RW_DATA_BROKEN; - if (fileName != "" && !pspFileSystem.GetFileInfo(filePath).exists) { + if (!fileName.empty() && !pspFileSystem.GetFileInfo(filePath).exists) { return SCE_UTILITY_SAVEDATA_ERROR_RW_FILE_NOT_FOUND; } - if (fileName == "") { + if (fileName.empty()) { return 0; } @@ -533,7 +533,7 @@ int SavedataParam::Save(SceUtilitySavedataParam* param, const std::string &saveD // copy back save name in request strncpy(param->saveName, saveDirName.c_str(), 20); - if (fileName == "") { + if (fileName.empty()) { delete[] cryptedData; } else { if (!WritePSPFile(filePath, data_, saveSize)) { @@ -583,13 +583,12 @@ int SavedataParam::Load(SceUtilitySavedataParam *param, const std::string &saveD std::string dirPath = GetSaveFilePath(param, GetSaveDir(param, saveDirName)); std::string fileName = GetFileName(param); std::string filePath = dirPath + "/" + fileName; - std::string sfoPath = dirPath + "/" + SFO_FILENAME; if (!pspFileSystem.GetFileInfo(dirPath).exists) { return isRWMode ? SCE_UTILITY_SAVEDATA_ERROR_RW_NO_DATA : SCE_UTILITY_SAVEDATA_ERROR_LOAD_NO_DATA; } - if (fileName != "" && !pspFileSystem.GetFileInfo(filePath).exists) { + if (!fileName.empty() && !pspFileSystem.GetFileInfo(filePath).exists) { return isRWMode ? SCE_UTILITY_SAVEDATA_ERROR_RW_FILE_NOT_FOUND : SCE_UTILITY_SAVEDATA_ERROR_LOAD_FILE_NOT_FOUND; } @@ -637,7 +636,7 @@ int SavedataParam::LoadSaveData(SceUtilitySavedataParam *param, const std::strin std::string filename = GetFileName(param); std::string filePath = dirPath + "/" + filename; // Blank filename always means success, if secureVersion was correct. - if (filename == "") + if (filename.empty()) return 0; s64 readSize; @@ -1576,7 +1575,7 @@ void SavedataParam::SetFileInfo(SaveFileInfo &saveInfo, PSPFileInfo &info, std:: saveInfo.idx = 0; saveInfo.modif_time = info.mtime; - std::string saveDir = savrDir == "" ? GetGameName(pspParam) + saveName : savrDir; + std::string saveDir = savrDir.empty() ? GetGameName(pspParam) + saveName : savrDir; saveInfo.saveDir = saveDir; // Start with a blank slate. diff --git a/Core/ELF/ParamSFO.cpp b/Core/ELF/ParamSFO.cpp index 71d07dcaca..a2c002f46e 100644 --- a/Core/ELF/ParamSFO.cpp +++ b/Core/ELF/ParamSFO.cpp @@ -283,7 +283,7 @@ std::string ParamSFOData::GenerateFakeID(std::string filename) { // Generates fake gameID for homebrew based on it's folder name. // Should probably not be a part of ParamSFO, but it'll be called in same places. std::string file = PSP_CoreParameter().fileToStart.ToString(); - if (filename != "") + if (!filename.empty()) file = filename; std::size_t lslash = file.find_last_of("/"); diff --git a/Core/FileSystems/VirtualDiscFileSystem.cpp b/Core/FileSystems/VirtualDiscFileSystem.cpp index c3a339172d..9a9e0f8c8b 100644 --- a/Core/FileSystems/VirtualDiscFileSystem.cpp +++ b/Core/FileSystems/VirtualDiscFileSystem.cpp @@ -329,7 +329,7 @@ int VirtualDiscFileSystem::OpenFile(std::string filename, FileAccess access, con entry.size = 0; entry.startOffset = 0; - if (filename == "") + if (filename.empty()) { entry.type = VFILETYPE_ISO; entry.fileIndex = -1; diff --git a/Core/HLE/proAdhoc.cpp b/Core/HLE/proAdhoc.cpp index dcacbcc5bd..8959b337b2 100644 --- a/Core/HLE/proAdhoc.cpp +++ b/Core/HLE/proAdhoc.cpp @@ -1325,7 +1325,7 @@ void sendChat(std::string chatString) { if (IsSocketReady((int)metasocket, false, true) > 0) { int chatResult = send((int)metasocket, (const char*)&chat, sizeof(chat), MSG_NOSIGNAL); NOTICE_LOG(SCENET, "Send Chat %s to Adhoc Server", chat.message); - std::string name = g_Config.sNickName.c_str(); + std::string name = g_Config.sNickName; std::lock_guard guard(chatLogLock); chatLog.push_back(name.substr(0, 8) + ": " + chat.message); @@ -1891,6 +1891,7 @@ uint32_t getLocalIp(int sock) { static std::vector> InitPrivateIPRanges() { struct sockaddr_in saNet {}, saMask{}; std::vector> ip_ranges; + ip_ranges.reserve(5); if (1 == inet_pton(AF_INET, "192.168.0.0", &(saNet.sin_addr)) && 1 == inet_pton(AF_INET, "255.255.0.0", &(saMask.sin_addr))) ip_ranges.push_back({saNet.sin_addr.s_addr, saMask.sin_addr.s_addr}); diff --git a/Core/HLE/sceNet.cpp b/Core/HLE/sceNet.cpp index c2a8987408..13b87f6b6b 100644 --- a/Core/HLE/sceNet.cpp +++ b/Core/HLE/sceNet.cpp @@ -691,7 +691,7 @@ static u32 sceWlanGetEtherAddr(u32 addrAddr) { addr[0] &= 0xfc; } else { // Read MAC Address from config - if (!ParseMacAddress(g_Config.sMACAddress.c_str(), addr)) { + if (!ParseMacAddress(g_Config.sMACAddress, addr)) { ERROR_LOG(SCENET, "Error parsing mac address %s", g_Config.sMACAddress.c_str()); Memory::Memset(addrAddr, 0, 6); } diff --git a/Core/MIPS/MIPSAnalyst.cpp b/Core/MIPS/MIPSAnalyst.cpp index 2c4e11bea4..2b047a42b0 100644 --- a/Core/MIPS/MIPSAnalyst.cpp +++ b/Core/MIPS/MIPSAnalyst.cpp @@ -1420,6 +1420,7 @@ skip: std::vector GetOutputRegs(MIPSOpcode op) { std::vector vec; + vec.reserve(3); MIPSInfo info = MIPSGetInfo(op); if (info & OUT_RD) vec.push_back(MIPS_GET_RD(op)); if (info & OUT_RT) vec.push_back(MIPS_GET_RT(op)); diff --git a/GPU/GLES/ShaderManagerGLES.cpp b/GPU/GLES/ShaderManagerGLES.cpp index ccf15e9268..3a620a4d91 100644 --- a/GPU/GLES/ShaderManagerGLES.cpp +++ b/GPU/GLES/ShaderManagerGLES.cpp @@ -84,6 +84,7 @@ LinkedShader::LinkedShader(GLRenderManager *render, VShaderID VSID, Shader *vs, std::vector semantics; + semantics.reserve(7); semantics.push_back({ ATTR_POSITION, "position" }); semantics.push_back({ ATTR_TEXCOORD, "texcoord" }); if (useHWTransform_) @@ -185,6 +186,7 @@ LinkedShader::LinkedShader(GLRenderManager *render, VShaderID VSID, Shader *vs, availableUniforms = vs->GetUniformMask() | fs->GetUniformMask(); std::vector initialize; + initialize.reserve(7); initialize.push_back({ &u_tex, 0, TEX_SLOT_PSP_TEXTURE }); initialize.push_back({ &u_fbotex, 0, TEX_SLOT_SHADERBLEND_SRC }); initialize.push_back({ &u_testtex, 0, TEX_SLOT_ALPHATEST }); diff --git a/GPU/Software/DrawPixelX86.cpp b/GPU/Software/DrawPixelX86.cpp index 32e6aeb835..53f9c94279 100644 --- a/GPU/Software/DrawPixelX86.cpp +++ b/GPU/Software/DrawPixelX86.cpp @@ -1737,6 +1737,7 @@ bool PixelJitCache::Jit_ApplyLogicOp(const PixelFuncID &id, RegCache::Reg colorR } std::vector finishes; + finishes.reserve(11); FixupBranch skipTable = J(true); const u8 *tableValues[16]{}; diff --git a/UI/ChatScreen.cpp b/UI/ChatScreen.cpp index 01421ee733..3a12597d11 100644 --- a/UI/ChatScreen.cpp +++ b/UI/ChatScreen.cpp @@ -138,7 +138,7 @@ void ChatMenu::UpdateChat() { uint32_t textcolor = 0xFFFFFF; uint32_t infocolor = 0xFDD835; - std::string name = g_Config.sNickName.c_str(); + std::string name = g_Config.sNickName; std::string displayname = i.substr(0, i.find(':')); std::string chattext = i.substr(displayname.length()); diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index d58e23c704..486d502d4d 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -256,7 +256,7 @@ void GameSettingsScreen::CreateViews() { root_->Add(settingInfo_); // Show it again if we recreated the view - if (oldSettingInfo_ != "") { + if (!oldSettingInfo_.empty()) { settingInfo_->Show(oldSettingInfo_, nullptr); } @@ -1222,7 +1222,7 @@ UI::EventReturn GameSettingsScreen::OnChangeMemStickDir(UI::EventParams &e) { } UI::EventReturn GameSettingsScreen::OnOpenMemStick(UI::EventParams &e) { - OpenDirectory(File::ResolvePath(g_Config.memStickDirectory.ToString().c_str()).c_str()); + OpenDirectory(File::ResolvePath(g_Config.memStickDirectory.ToString()).c_str()); return UI::EVENT_DONE; } diff --git a/UI/MemStickScreen.cpp b/UI/MemStickScreen.cpp index ba61ad193a..78c4cf24fd 100644 --- a/UI/MemStickScreen.cpp +++ b/UI/MemStickScreen.cpp @@ -259,7 +259,7 @@ void MemStickScreen::CreateViews() { privateString = StringFromFormat("%s (%s)", iz->T("Skip for now"), privateString.c_str()); } - leftColumn->Add(new RadioButton(&choice_, CHOICE_PRIVATE_DIRECTORY, privateString.c_str()))->OnClick.Handle(this, &MemStickScreen::OnChoiceClick); + leftColumn->Add(new RadioButton(&choice_, CHOICE_PRIVATE_DIRECTORY, privateString))->OnClick.Handle(this, &MemStickScreen::OnChoiceClick); if (choice_ == CHOICE_PRIVATE_DIRECTORY) { AddExplanation(leftColumn, (MemStickScreen::Choice)choice_); } diff --git a/UI/RemoteISOScreen.cpp b/UI/RemoteISOScreen.cpp index 4497f169db..7d60e507a4 100644 --- a/UI/RemoteISOScreen.cpp +++ b/UI/RemoteISOScreen.cpp @@ -176,7 +176,7 @@ bool RemoteISOConnectScreen::FindServer(std::string &resultHost, int &resultPort }; // Try last server first, if it is set - if (g_Config.iLastRemoteISOPort && g_Config.sLastRemoteISOServer != "") { + if (g_Config.iLastRemoteISOPort && !g_Config.sLastRemoteISOServer.empty()) { if (TryServer(g_Config.sLastRemoteISOServer.c_str(), g_Config.iLastRemoteISOPort)) { return true; } diff --git a/UI/Theme.cpp b/UI/Theme.cpp index 978eeb3d0b..464c4ab2db 100644 --- a/UI/Theme.cpp +++ b/UI/Theme.cpp @@ -139,7 +139,7 @@ static void LoadThemeInfo(const std::vector &directories) { std::string tmpPath; section.Get("UIAtlas", &tmpPath, ""); - if (tmpPath != "") { + if (!tmpPath.empty()) { tmpPath = (path / tmpPath).ToString(); File::FileInfo tmpInfo; diff --git a/Windows/Debugger/CtrlMemView.cpp b/Windows/Debugger/CtrlMemView.cpp index e5af6aaa8d..220ad0a99e 100644 --- a/Windows/Debugger/CtrlMemView.cpp +++ b/Windows/Debugger/CtrlMemView.cpp @@ -768,6 +768,7 @@ std::vector CtrlMemView::searchString(const std::string &searchQuery) { std::vector> memoryAreas; memoryAreas.push_back(std::pair(PSP_GetScratchpadMemoryBase(), PSP_GetScratchpadMemoryEnd())); + memoryAreas.reserve(3); // Ignore the video memory mirrors. memoryAreas.push_back(std::pair(PSP_GetVidMemBase(), 0x04200000)); memoryAreas.push_back(std::pair(PSP_GetKernelMemoryBase(), PSP_GetUserMemoryEnd())); @@ -821,6 +822,7 @@ void CtrlMemView::search(bool continueSearch) } std::vector> memoryAreas; + memoryAreas.reserve(3); // Ignore the video memory mirrors. memoryAreas.push_back(std::pair(PSP_GetVidMemBase(), 0x04200000)); memoryAreas.push_back(std::pair(PSP_GetKernelMemoryBase(), PSP_GetUserMemoryEnd())); diff --git a/Windows/Debugger/Debugger_MemoryDlg.cpp b/Windows/Debugger/Debugger_MemoryDlg.cpp index d5358ab1bc..d016afaafa 100644 --- a/Windows/Debugger/Debugger_MemoryDlg.cpp +++ b/Windows/Debugger/Debugger_MemoryDlg.cpp @@ -195,7 +195,7 @@ BOOL CMemoryDlg::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) { switch (HIWORD(wParam)) { case BN_CLICKED: GetWindowText(searchBoxHdl, temp, 255); - std::vector results = memView->searchString(ConvertWStringToUTF8(temp).c_str()); + std::vector results = memView->searchString(ConvertWStringToUTF8(temp)); if (results.size() > 0){ searchBoxRedraw(results); } diff --git a/Windows/W32Util/ShellUtil.cpp b/Windows/W32Util/ShellUtil.cpp index c6d3a2bc49..151cd643ce 100644 --- a/Windows/W32Util/ShellUtil.cpp +++ b/Windows/W32Util/ShellUtil.cpp @@ -199,7 +199,7 @@ namespace W32Util switch (type_) { case DIR: filename_ = BrowseForFolder(parent_, title_.c_str()); - result_ = filename_ != ""; + result_ = !filename_.empty(); complete_ = true; break;