diff --git a/Common/Data/Encoding/Compression.cpp b/Common/Data/Encoding/Compression.cpp index 751a9595cf..3e2e499a18 100644 --- a/Common/Data/Encoding/Compression.cpp +++ b/Common/Data/Encoding/Compression.cpp @@ -95,7 +95,6 @@ bool decompress_string(const std::string& str, std::string *dest) { inflateEnd(&zs); if (ret != Z_STREAM_END) { // an error occurred that was not EOF - std::ostringstream oss; ERROR_LOG(IO, "Exception during zlib decompression: (%i) %s", ret, zs.msg); return false; } diff --git a/Common/Data/Format/IniFile.cpp b/Common/Data/Format/IniFile.cpp index 32fcf43b68..cd2a658e5c 100644 --- a/Common/Data/Format/IniFile.cpp +++ b/Common/Data/Format/IniFile.cpp @@ -206,7 +206,7 @@ void Section::Set(const char* key, const char* newValue) else { // The key did not already exist in this section - let's add it. - lines.push_back(std::string(key) + " = " + EscapeComments(newValue)); + lines.emplace_back(std::string(key) + " = " + EscapeComments(newValue)); } } @@ -272,7 +272,7 @@ void Section::Set(const char* key, const std::vector& newValues) } void Section::AddComment(const std::string &comment) { - lines.push_back("# " + comment); + lines.emplace_back("# " + comment); } bool Section::Get(const char* key, std::vector& values) 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/DirListing.cpp b/Common/File/DirListing.cpp index abe5ff3af8..2f7178847b 100644 --- a/Common/File/DirListing.cpp +++ b/Common/File/DirListing.cpp @@ -148,7 +148,7 @@ std::vector ApplyFilter(std::vector files, const std::string tmp; while (*filter) { if (*filter == ':') { - filters.insert("." + tmp); + filters.emplace("." + tmp); tmp.clear(); } else { tmp.push_back(*filter); @@ -156,7 +156,7 @@ std::vector ApplyFilter(std::vector files, const filter++; } if (!tmp.empty()) - filters.insert("." + tmp); + filters.emplace("." + tmp); } auto pred = [&](const File::FileInfo &info) { diff --git a/Common/File/Path.cpp b/Common/File/Path.cpp index ba3372e78a..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) { @@ -357,7 +357,6 @@ bool Path::ComputePathTo(const Path &other, std::string &path) const { return true; } - std::string diff; if (type_ == PathType::CONTENT_URI) { AndroidContentURI a(path_); AndroidContentURI b(other.path_); diff --git a/Common/GPU/D3D9/D3D9ShaderCompiler.cpp b/Common/GPU/D3D9/D3D9ShaderCompiler.cpp index f41ea3911d..d3821066aa 100644 --- a/Common/GPU/D3D9/D3D9ShaderCompiler.cpp +++ b/Common/GPU/D3D9/D3D9ShaderCompiler.cpp @@ -47,7 +47,7 @@ LPD3DBLOB CompileShaderToByteCodeD3D9(const char *code, const char *target, std: pShaderCode = nullptr; } } else { - *errorMessage = ""; + errorMessage->clear(); } return pShaderCode; diff --git a/Common/GPU/OpenGL/GLFeatures.cpp b/Common/GPU/OpenGL/GLFeatures.cpp index bf9a639e67..aa79ac5941 100644 --- a/Common/GPU/OpenGL/GLFeatures.cpp +++ b/Common/GPU/OpenGL/GLFeatures.cpp @@ -51,7 +51,7 @@ static void ParseExtensionsString(const std::string& str, std::set size_t next = 0; for (size_t pos = 0, len = str.length(); pos < len; ++pos) { if (str[pos] == ' ') { - output.insert(str.substr(next, pos - next)); + output.emplace(str.substr(next, pos - next)); // Skip the delimiter itself. next = pos + 1; } @@ -60,7 +60,7 @@ static void ParseExtensionsString(const std::string& str, std::set if (next == 0 && str.length() != 0) { output.insert(str); } else if (next < str.length()) { - output.insert(str.substr(next)); + output.emplace(str.substr(next)); } } diff --git a/Common/GPU/OpenGL/thin3d_gl.cpp b/Common/GPU/OpenGL/thin3d_gl.cpp index f757d3f554..95e737e63a 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/Common/GPU/ShaderTranslation.cpp b/Common/GPU/ShaderTranslation.cpp index 54b4fab0f1..9391d1b7da 100644 --- a/Common/GPU/ShaderTranslation.cpp +++ b/Common/GPU/ShaderTranslation.cpp @@ -235,7 +235,7 @@ bool TranslateShader(std::string *dest, ShaderLanguage destLang, const ShaderLan return false; #endif - *errorMessage = ""; + errorMessage->clear(); glslang::TProgram program; const char *shaderStrings[1]{}; diff --git a/Common/GPU/Vulkan/VulkanQueueRunner.cpp b/Common/GPU/Vulkan/VulkanQueueRunner.cpp index 428d66e2cc..3eee8f7ad7 100644 --- a/Common/GPU/Vulkan/VulkanQueueRunner.cpp +++ b/Common/GPU/Vulkan/VulkanQueueRunner.cpp @@ -1348,7 +1348,6 @@ void VulkanQueueRunner::PerformRenderPass(const VKRStep &step, VkCommandBuffer c int n = 0; int stage = 0; - VkImageMemoryBarrier barriers[2]{}; if (step.render.framebuffer->color.layout == VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL) { recordBarrier_.TransitionImage( step.render.framebuffer->color.image, @@ -1758,9 +1757,6 @@ void VulkanQueueRunner::PerformBlit(const VKRStep &step, VkCommandBuffer cmd) { // The barrier code doesn't handle this case. We'd need to transition to GENERAL to do an intra-image copy. _dbg_assert_(step.blit.src != step.blit.dst); - VkImageMemoryBarrier srcBarriers[2]{}; - VkImageMemoryBarrier dstBarriers[2]{}; - VKRFramebuffer *src = step.blit.src; VKRFramebuffer *dst = step.blit.dst; diff --git a/Common/GPU/Vulkan/thin3d_vulkan.cpp b/Common/GPU/Vulkan/thin3d_vulkan.cpp index 06e026d35c..cf2a28ea53 100644 --- a/Common/GPU/Vulkan/thin3d_vulkan.cpp +++ b/Common/GPU/Vulkan/thin3d_vulkan.cpp @@ -1083,6 +1083,7 @@ Pipeline *VKContext::CreateGraphicsPipeline(const PipelineDesc &desc, const char gDesc.fragmentShader = vkshader->Get(); } else { ERROR_LOG(G3D, "Bad stage"); + delete pipeline; return nullptr; } } @@ -1424,7 +1425,7 @@ std::vector VKContext::GetFeatureList() const { AddFeature(features, "occlusionQueryPrecise", available.occlusionQueryPrecise, enabled.occlusionQueryPrecise); AddFeature(features, "multiDrawIndirect", available.multiDrawIndirect, enabled.multiDrawIndirect); - features.push_back(std::string("Preferred depth buffer format: ") + VulkanFormatToString(vulkan_->GetDeviceInfo().preferredDepthStencilFormat)); + features.emplace_back(std::string("Preferred depth buffer format: ") + VulkanFormatToString(vulkan_->GetDeviceInfo().preferredDepthStencilFormat)); return features; } diff --git a/Common/LogReporting.cpp b/Common/LogReporting.cpp index 2189b1c7e2..0fcc78d0ad 100644 --- a/Common/LogReporting.cpp +++ b/Common/LogReporting.cpp @@ -35,7 +35,7 @@ bool ShouldLogNTimes(const char *identifier, int count) { std::lock_guard lock(logNTimesLock); auto iter = logNTimes.find(identifier); if (iter == logNTimes.end()) { - logNTimes.insert(std::pair(identifier, 1)); + logNTimes.emplace(identifier, 1); return true; } else { if (iter->second >= count) { diff --git a/Common/StringUtils.cpp b/Common/StringUtils.cpp index f88f6194ab..3a9e29c61a 100644 --- a/Common/StringUtils.cpp +++ b/Common/StringUtils.cpp @@ -273,7 +273,7 @@ void SplitString(const std::string& str, const char delim, std::vector& output) if (str[pos] == '\"' || str[pos] == '\'') { if (even) { //quoted text - output.push_back(str.substr(next, pos - next)); + output.emplace_back(str.substr(next, pos - next)); even = 0; } else { //non quoted text diff --git a/Core/Config.cpp b/Core/Config.cpp index dee26c3793..4eeca428ab 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -1425,7 +1425,7 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) { // build of PPSSPP, receive an upgrade notice, then start a newer version, and still receive the upgrade notice, // even if said newer version is >= the upgrade found online. if ((dismissedVersion == upgradeVersion) || (versionsValid && (installed >= upgrade))) { - upgradeMessage = ""; + upgradeMessage.clear(); } // Check for new version on every 10 runs. @@ -1637,16 +1637,16 @@ void Config::DownloadCompletedCallback(http::Download &download) { if (installed >= upgrade) { INFO_LOG(LOADER, "Version check: Already up to date, erasing any upgrade message"); - g_Config.upgradeMessage = ""; + g_Config.upgradeMessage.clear(); g_Config.upgradeVersion = upgrade.ToString(); - g_Config.dismissedVersion = ""; + g_Config.dismissedVersion.clear(); return; } if (installed < upgrade && dismissed != upgrade) { g_Config.upgradeMessage = "New version of PPSSPP available!"; g_Config.upgradeVersion = upgrade.ToString(); - g_Config.dismissedVersion = ""; + g_Config.dismissedVersion.clear(); } } diff --git a/Core/Core.cpp b/Core/Core.cpp index 52a1df8f4c..c1bb28cefd 100644 --- a/Core/Core.cpp +++ b/Core/Core.cpp @@ -447,7 +447,7 @@ void Core_MemoryException(u32 address, u32 pc, MemoryExceptionType type) { ExceptionInfo &e = g_exceptionInfo; e = {}; e.type = ExceptionType::MEMORY; - e.info = ""; + e.info.clear(); e.memory_type = type; e.address = address; e.pc = pc; @@ -483,7 +483,7 @@ void Core_ExecException(u32 address, u32 pc, ExecExceptionType type) { ExceptionInfo &e = g_exceptionInfo; e = {}; e.type = ExceptionType::BAD_EXEC_ADDR; - e.info = ""; + e.info.clear(); e.exec_type = type; e.address = address; e.pc = pc; @@ -498,7 +498,7 @@ void Core_Break(u32 pc) { ExceptionInfo &e = g_exceptionInfo; e = {}; e.type = ExceptionType::BREAK; - e.info = ""; + e.info.clear(); e.pc = pc; if (!g_Config.bIgnoreBadMemAccess) { diff --git a/Core/Debugger/DisassemblyManager.cpp b/Core/Debugger/DisassemblyManager.cpp index 511aeee82a..ab0e10aa9b 100644 --- a/Core/Debugger/DisassemblyManager.cpp +++ b/Core/Debugger/DisassemblyManager.cpp @@ -316,7 +316,7 @@ void DisassemblyManager::getLine(u32 address, bool insertSymbols, DisassemblyLin dest.params = "Disassembly failure"; } else { dest.name = "-"; - dest.params = ""; + dest.params.clear(); } } @@ -1003,7 +1003,7 @@ void DisassemblyData::createLines() lines[currentLineStart] = entry; lineAddresses.push_back(currentLineStart); - currentLine = ""; + currentLine.clear(); currentLineStart = pos-1; inString = false; } @@ -1028,7 +1028,7 @@ void DisassemblyData::createLines() lines[currentLineStart] = entry; lineAddresses.push_back(currentLineStart); - currentLine = ""; + currentLine.clear(); currentLineStart = pos-1; inString = false; } @@ -1099,7 +1099,7 @@ void DisassemblyData::createLines() lines[currentLineStart] = entry; lineAddresses.push_back(currentLineStart); - currentLine = ""; + currentLine.clear(); currentLineStart = currentPos; } diff --git a/Core/Debugger/SymbolMap.cpp b/Core/Debugger/SymbolMap.cpp index 8f851fc6f5..63e087d7a8 100644 --- a/Core/Debugger/SymbolMap.cpp +++ b/Core/Debugger/SymbolMap.cpp @@ -440,7 +440,7 @@ void SymbolMap::AddModule(const char *name, u32 address, u32 size) { // Just reactivate that one. it->start = address; it->size = size; - activeModuleEnds.insert(std::make_pair(it->start + it->size, *it)); + activeModuleEnds.emplace(it->start + it->size, *it); activeNeedUpdate_ = true; return; } @@ -453,7 +453,7 @@ void SymbolMap::AddModule(const char *name, u32 address, u32 size) { mod.index = (int)modules.size() + 1; modules.push_back(mod); - activeModuleEnds.insert(std::make_pair(mod.start + mod.size, mod)); + activeModuleEnds.emplace(mod.start + mod.size, mod); activeNeedUpdate_ = true; } @@ -560,7 +560,7 @@ void SymbolMap::AddFunction(const char* name, u32 address, u32 size, int moduleI auto active = activeFunctions.find(address); if (active != activeFunctions.end() && active->second.module == moduleIndex) { activeFunctions.erase(active); - activeFunctions.insert(std::make_pair(address, existing->second)); + activeFunctions.emplace(address, existing->second); } } else { FunctionEntry func; @@ -571,7 +571,7 @@ void SymbolMap::AddFunction(const char* name, u32 address, u32 size, int moduleI functions[symbolKey] = func; if (IsModuleActive(moduleIndex)) { - activeFunctions.insert(std::make_pair(address, func)); + activeFunctions.emplace(address, func); } } @@ -717,27 +717,27 @@ void SymbolMap::UpdateActiveSymbols() { for (auto it = functions.begin(), end = functions.end(); it != end; ++it) { const auto mod = activeModuleIndexes.find(it->second.module); if (it->second.module == 0) { - activeFunctions.insert(std::make_pair(it->second.start, it->second)); + activeFunctions.emplace(it->second.start, it->second); } else if (mod != activeModuleIndexes.end()) { - activeFunctions.insert(std::make_pair(mod->second + it->second.start, it->second)); + activeFunctions.emplace(mod->second + it->second.start, it->second); } } for (auto it = labels.begin(), end = labels.end(); it != end; ++it) { const auto mod = activeModuleIndexes.find(it->second.module); if (it->second.module == 0) { - activeLabels.insert(std::make_pair(it->second.addr, it->second)); + activeLabels.emplace(it->second.addr, it->second); } else if (mod != activeModuleIndexes.end()) { - activeLabels.insert(std::make_pair(mod->second + it->second.addr, it->second)); + activeLabels.emplace(mod->second + it->second.addr, it->second); } } for (auto it = data.begin(), end = data.end(); it != end; ++it) { const auto mod = activeModuleIndexes.find(it->second.module); if (it->second.module == 0) { - activeData.insert(std::make_pair(it->second.start, it->second)); + activeData.emplace(it->second.start, it->second); } else if (mod != activeModuleIndexes.end()) { - activeData.insert(std::make_pair(mod->second + it->second.start, it->second)); + activeData.emplace(mod->second + it->second.start, it->second); } } @@ -758,7 +758,7 @@ bool SymbolMap::SetFunctionSize(u32 startAddress, u32 newSize) { if (func != functions.end()) { func->second.size = newSize; activeFunctions.erase(funcInfo); - activeFunctions.insert(std::make_pair(startAddress, func->second)); + activeFunctions.emplace(startAddress, func->second); } } @@ -830,7 +830,7 @@ void SymbolMap::AddLabel(const char* name, u32 address, int moduleIndex) { auto active = activeLabels.find(address); if (active != activeLabels.end() && active->second.module == moduleIndex) { activeLabels.erase(active); - activeLabels.insert(std::make_pair(address, label)); + activeLabels.emplace(address, label); } } } else { @@ -841,7 +841,7 @@ void SymbolMap::AddLabel(const char* name, u32 address, int moduleIndex) { labels[symbolKey] = label; if (IsModuleActive(moduleIndex)) { - activeLabels.insert(std::make_pair(address, label)); + activeLabels.emplace(address, label); } } } @@ -865,7 +865,7 @@ void SymbolMap::SetLabelName(const char* name, u32 address) { auto active = activeLabels.find(address); if (active != activeLabels.end() && active->second.module == label->second.module) { activeLabels.erase(active); - activeLabels.insert(std::make_pair(address, label->second)); + activeLabels.emplace(address, label->second); } } } @@ -948,7 +948,7 @@ void SymbolMap::AddData(u32 address, u32 size, DataType type, int moduleIndex) { auto active = activeData.find(address); if (active != activeData.end() && active->second.module == moduleIndex) { activeData.erase(active); - activeData.insert(std::make_pair(address, existing->second)); + activeData.emplace(address, existing->second); } } else { DataEntry entry; @@ -959,7 +959,7 @@ void SymbolMap::AddData(u32 address, u32 size, DataType type, int moduleIndex) { data[symbolKey] = entry; if (IsModuleActive(moduleIndex)) { - activeData.insert(std::make_pair(address, entry)); + activeData.emplace(address, entry); } } } diff --git a/Core/Debugger/WebSocket/WebSocketUtils.cpp b/Core/Debugger/WebSocket/WebSocketUtils.cpp index cc49e33336..3ba5984f4b 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; } @@ -262,7 +262,7 @@ bool DebuggerRequest::ParamString(const char *name, std::string *out, DebuggerPa return true; } else if (tag == JSON_NULL) { if (required) { - *out = ""; + out->clear(); } return true; } else if (tag == JSON_NUMBER) { 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 5a04ebc882..67ef655ccf 100644 --- a/Core/Dialog/SavedataParam.cpp +++ b/Core/Dialog/SavedataParam.cpp @@ -258,7 +258,7 @@ std::string SavedataParam::GetSaveFilePath(const SceUtilitySavedataParam *param, inline static std::string FixedToString(const char *str, size_t n) { if (!str) { - return std::string(""); + return std::string(); } else { return std::string(str, strnlen(str, n)); } @@ -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/ISOFileSystem.cpp b/Core/FileSystems/ISOFileSystem.cpp index a873f3f19b..0d57bf2848 100644 --- a/Core/FileSystems/ISOFileSystem.cpp +++ b/Core/FileSystems/ISOFileSystem.cpp @@ -148,7 +148,7 @@ ISOFileSystem::ISOFileSystem(IHandleAllocator *_hAlloc, BlockDevice *_blockDevic if (!blockDevice->ReadBlock(16, (u8*)&desc)) blockDevice->NotifyReadError(); - entireISO.name = ""; + entireISO.name.clear(); entireISO.isDirectory = false; entireISO.startingPosition = 0; entireISO.size = _blockDevice->GetNumBlocks(); diff --git a/Core/FileSystems/VirtualDiscFileSystem.cpp b/Core/FileSystems/VirtualDiscFileSystem.cpp index dd41e95855..9a9e0f8c8b 100644 --- a/Core/FileSystems/VirtualDiscFileSystem.cpp +++ b/Core/FileSystems/VirtualDiscFileSystem.cpp @@ -81,7 +81,6 @@ void VirtualDiscFileSystem::LoadFileListIndex() { return; } - std::string buf; static const int MAX_LINE_SIZE = 2048; char linebuf[MAX_LINE_SIZE]{}; while (fgets(linebuf, MAX_LINE_SIZE, f)) { @@ -330,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..dfcc535df0 100644 --- a/Core/HLE/proAdhoc.cpp +++ b/Core/HLE/proAdhoc.cpp @@ -1325,10 +1325,10 @@ 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); + chatLog.emplace_back(name.substr(0, 8) + ": " + chat.message); chatMessageGeneration++; } } @@ -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}); @@ -1928,7 +1929,7 @@ void getLocalMac(SceNetEtherAddr * addr){ mac[0] &= 0xfc; } else - if (!ParseMacAddress(g_Config.sMACAddress.c_str(), mac)) { + if (!ParseMacAddress(g_Config.sMACAddress, mac)) { ERROR_LOG(SCENET, "Error parsing mac address %s", g_Config.sMACAddress.c_str()); memset(&mac, 0, sizeof(mac)); } diff --git a/Core/HLE/sceKernelMemory.cpp b/Core/HLE/sceKernelMemory.cpp index 318cae7d0c..55b7ff7044 100644 --- a/Core/HLE/sceKernelMemory.cpp +++ b/Core/HLE/sceKernelMemory.cpp @@ -2007,7 +2007,7 @@ int __KernelFreeTls(TLSPL *tls, SceUID threadID) __KernelResumeThreadFromWait(waitingThreadID, freedAddress); // Gotta watch the thread to quit as well, since they've allocated now. - tlsplThreadEndChecks.insert(std::make_pair(waitingThreadID, uid)); + tlsplThreadEndChecks.emplace(waitingThreadID, uid); // No need to continue or free it, we're done. return 0; @@ -2234,7 +2234,7 @@ int sceKernelGetTlsAddr(SceUID uid) { if (allocBlock != -1) { tls->usage[allocBlock] = threadID; - tlsplThreadEndChecks.insert(std::make_pair(threadID, uid)); + tlsplThreadEndChecks.emplace(threadID, uid); --tls->ntls.freeBlocks; needsClear = true; } diff --git a/Core/HLE/sceKernelMutex.cpp b/Core/HLE/sceKernelMutex.cpp index 2cba7b5ca5..6921ffdf26 100644 --- a/Core/HLE/sceKernelMutex.cpp +++ b/Core/HLE/sceKernelMutex.cpp @@ -213,7 +213,7 @@ static void __KernelMutexAcquireLock(PSPMutex *mutex, int count, SceUID thread) _dbg_assert_msg_((*iter).second != mutex->GetUID(), "Thread %d / mutex %d wasn't removed from mutexHeldLocks properly.", thread, mutex->GetUID()); #endif - mutexHeldLocks.insert(std::make_pair(thread, mutex->GetUID())); + mutexHeldLocks.emplace(thread, mutex->GetUID()); mutex->nm.lockLevel = count; mutex->nm.lockThread = thread; diff --git a/Core/HLE/sceKernelThread.cpp b/Core/HLE/sceKernelThread.cpp index ea9caaba1e..f717cd5a3e 100644 --- a/Core/HLE/sceKernelThread.cpp +++ b/Core/HLE/sceKernelThread.cpp @@ -230,7 +230,7 @@ public: MipsCallManager() : idGen_(0) {} u32 add(MipsCall *call) { u32 id = genId(); - calls_.insert(std::pair(id, call)); + calls_.emplace(id, call); return id; } MipsCall *get(u32 id) { 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/HW/Display.cpp b/Core/HW/Display.cpp index ebabb647d0..1dcb51e18c 100644 --- a/Core/HW/Display.cpp +++ b/Core/HW/Display.cpp @@ -265,7 +265,7 @@ void __DisplayListenVblank(VblankCallback callback) { void __DisplayListenFlip(FlipCallback callback, void *userdata) { std::lock_guard guard(listenersLock); - flipListeners.push_back(std::make_pair(callback, userdata)); + flipListeners.emplace_back(callback, userdata); } void __DisplayForgetFlip(FlipCallback callback, void *userdata) { diff --git a/Core/Loaders.cpp b/Core/Loaders.cpp index 09ac48f47f..37722fe0cf 100644 --- a/Core/Loaders.cpp +++ b/Core/Loaders.cpp @@ -60,7 +60,7 @@ FileLoader *ConstructFileLoader(const Path &filename) { // TODO : improve, look in the file more IdentifiedFileType Identify_File(FileLoader *fileLoader, std::string *errorString) { - *errorString = ""; + errorString->clear(); if (fileLoader == nullptr) { *errorString = "Invalid fileLoader"; return IdentifiedFileType::ERROR_IDENTIFYING; diff --git a/Core/MIPS/JitCommon/JitBlockCache.cpp b/Core/MIPS/JitCommon/JitBlockCache.cpp index b85b336fcd..f5b11ca4a5 100644 --- a/Core/MIPS/JitCommon/JitBlockCache.cpp +++ b/Core/MIPS/JitCommon/JitBlockCache.cpp @@ -198,7 +198,7 @@ void JitBlockCache::ProxyBlock(u32 rootAddress, u32 startAddress, u32 size, cons // Make binary searches and stuff work ok b.normalEntry = codePtr; b.checkedEntry = codePtr; - proxyBlockMap_.insert(std::make_pair(startAddress, num_blocks_)); + proxyBlockMap_.emplace(startAddress, num_blocks_); AddBlockMap(num_blocks_); num_blocks_++; //commit the current block @@ -253,7 +253,7 @@ void JitBlockCache::FinalizeBlock(int block_num, bool block_link) { if (block_link) { for (int i = 0; i < MAX_JIT_BLOCK_EXITS; i++) { if (b.exitAddress[i] != INVALID_EXIT) { - links_to_.insert(std::make_pair(b.exitAddress[i], block_num)); + links_to_.emplace(b.exitAddress[i], block_num); } } diff --git a/Core/MIPS/MIPSAnalyst.cpp b/Core/MIPS/MIPSAnalyst.cpp index 2c4e11bea4..81f87da663 100644 --- a/Core/MIPS/MIPSAnalyst.cpp +++ b/Core/MIPS/MIPSAnalyst.cpp @@ -771,7 +771,7 @@ namespace MIPSAnalyst { for (auto iter = functions.begin(); iter != functions.end(); iter++) { AnalyzedFunction &f = *iter; if (f.hasHash && f.size > 16) { - hashToFunction.insert(std::make_pair(f.hash, &f)); + hashToFunction.emplace(f.hash, &f); } } } @@ -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/Core/MIPS/MIPSAsm.cpp b/Core/MIPS/MIPSAsm.cpp index 25814af0e6..1c45f14ac5 100644 --- a/Core/MIPS/MIPSAsm.cpp +++ b/Core/MIPS/MIPSAsm.cpp @@ -80,7 +80,7 @@ bool MipsAssembleOpcode(const char *line, DebugInterface *cpu, u32 address) { g_symbolMap->GetLabels(args.labels); } - errorText = ""; + errorText.clear(); if (!runArmips(args)) { for (size_t i = 0; i < errors.size(); i++) diff --git a/Core/System.cpp b/Core/System.cpp index 9388d92820..cb6fc34fa8 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -427,7 +427,7 @@ bool PSP_InitStart(const CoreParameter &coreParam, std::string *error_string) { if (g_CoreParameter.graphicsContext == nullptr) { g_CoreParameter.graphicsContext = temp; } - g_CoreParameter.errorString = ""; + g_CoreParameter.errorString.clear(); pspIsIniting = true; PSP_SetLoading("Loading game..."); diff --git a/Core/Util/GameManager.cpp b/Core/Util/GameManager.cpp index b6f4ccbd65..e808f07b6c 100644 --- a/Core/Util/GameManager.cpp +++ b/Core/Util/GameManager.cpp @@ -674,7 +674,7 @@ bool GameManager::InstallRawISO(const Path &file, const std::string &originalNam void GameManager::ResetInstallError() { if (!installInProgress_) { - installError_ = ""; + installError_.clear(); } } diff --git a/Core/WebServer.cpp b/Core/WebServer.cpp index 3d6d9b37cb..4aff212eba 100644 --- a/Core/WebServer.cpp +++ b/Core/WebServer.cpp @@ -297,7 +297,7 @@ static void ForwardDebuggerRequest(const http::Request &request) { // Check if this is a websocket request... std::string upgrade; if (!request.GetHeader("upgrade", &upgrade)) { - upgrade = ""; + upgrade.clear(); } // Yes - proceed with the socket. diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index edd7cbb9fa..cf1eb06019 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -1974,6 +1974,7 @@ VirtualFramebuffer *FramebufferManagerCommon::FindDownloadTempBuffer(VirtualFram nvfb->fbo = draw_->CreateFramebuffer({ nvfb->bufferWidth, nvfb->bufferHeight, 1, 1, channel == RASTER_DEPTH ? true : false, name }); if (!nvfb->fbo) { ERROR_LOG(FRAMEBUF, "Error creating FBO! %d x %d", nvfb->renderWidth, nvfb->renderHeight); + delete nvfb; return nullptr; } bvfbs_.push_back(nvfb); diff --git a/GPU/Common/PostShader.cpp b/GPU/Common/PostShader.cpp index ed86397521..2d8529f356 100644 --- a/GPU/Common/PostShader.cpp +++ b/GPU/Common/PostShader.cpp @@ -55,7 +55,7 @@ void LoadPostShaderInfo(Draw::DrawContext *draw, const std::vector &direct off.name = "Off"; off.section = "Off"; for (size_t i = 0; i < ARRAY_SIZE(off.settings); ++i) { - off.settings[i].name = ""; + off.settings[i].name.clear(); off.settings[i].value = 0.0f; off.settings[i].minValue = -1.0f; off.settings[i].maxValue = 1.0f; @@ -174,7 +174,7 @@ void LoadPostShaderInfo(Draw::DrawContext *draw, const std::vector &direct section.Get("UsePreviousFrame", &info.usePreviousFrame, false); if (info.parent == "Off") - info.parent = ""; + info.parent.clear(); for (size_t i = 0; i < ARRAY_SIZE(info.settings); ++i) { auto &setting = info.settings[i]; @@ -187,7 +187,7 @@ void LoadPostShaderInfo(Draw::DrawContext *draw, const std::vector &direct // Populate the default setting value. std::string section = StringFromFormat("%sSettingValue%d", info.section.c_str(), i + 1); if (!setting.name.empty() && g_Config.mPostShaderSetting.find(section) == g_Config.mPostShaderSetting.end()) { - g_Config.mPostShaderSetting.insert(std::pair(section, setting.value)); + g_Config.mPostShaderSetting.emplace(section, setting.value); } } diff --git a/GPU/Common/ShaderId.cpp b/GPU/Common/ShaderId.cpp index eccd5d158f..9c8cb3905b 100644 --- a/GPU/Common/ShaderId.cpp +++ b/GPU/Common/ShaderId.cpp @@ -227,7 +227,7 @@ std::string FragmentShaderDesc(const FShaderID &id) { case STENCIL_VALUE_INCR_4: desc << "StenIncr4 "; break; case STENCIL_VALUE_INCR_8: desc << "StenIncr8 "; break; case STENCIL_VALUE_DECR_4: desc << "StenDecr4 "; break; - case STENCIL_VALUE_DECR_8: desc << "StenDecr4 "; break; + case STENCIL_VALUE_DECR_8: desc << "StenDecr8 "; break; default: desc << "StenUnknown "; break; } } else if (id.Bit(FS_BIT_REPLACE_ALPHA_WITH_STENCIL_TYPE)) { diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index d55f890f64..57ea8204cc 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -867,8 +867,6 @@ void TextureCacheCommon::NotifyFramebuffer(VirtualFramebuffer *framebuffer, Fram // Try to match the new framebuffer to existing textures. // Backwards from the "usual" texturing case so can't share a utility function. - std::vector candidates; - u64 cacheKey = (u64)fb_addr << 32; // If it has a clut, those are the low 32 bits, so it'll be inside this range. // Also, if it's a subsample of the buffer, it'll also be within the FBO. diff --git a/GPU/Debugger/Breakpoints.cpp b/GPU/Debugger/Breakpoints.cpp index 97fbca57ee..6da92e41ae 100644 --- a/GPU/Debugger/Breakpoints.cpp +++ b/GPU/Debugger/Breakpoints.cpp @@ -339,7 +339,7 @@ void AddAddressBreakpoint(u32 addr, bool temp) { } else { // Remove the temporary marking. breakPCsTemp.erase(addr); - breakPCs.insert(std::make_pair(addr, BreakpointInfo{})); + breakPCs.emplace(addr, BreakpointInfo{}); } breakPCsCount = breakPCs.size(); diff --git a/GPU/Debugger/Debugger.cpp b/GPU/Debugger/Debugger.cpp index b505521631..fa55ec6b8e 100644 --- a/GPU/Debugger/Debugger.cpp +++ b/GPU/Debugger/Debugger.cpp @@ -219,9 +219,9 @@ bool SetRestrictPrims(const char *rule) { // If there's nothing yet, add everything else. if (updated.empty()) { if (range.first > 0) - updated.push_back(std::make_pair(0, range.first - 1)); + updated.emplace_back(0, range.first - 1); if (range.second < MAX_PRIMS) - updated.push_back(std::make_pair(range.second + 1, MAX_PRIMS)); + updated.emplace_back(range.second + 1, MAX_PRIMS); continue; } @@ -240,7 +240,7 @@ bool SetRestrictPrims(const char *rule) { // We're slicing a hole in this subrange. int next = sub.second; sub.second = range.first - 1; - updated.push_back(std::make_pair(range.second + 1, next)); + updated.emplace_back(range.second + 1, next); continue; } diff --git a/GPU/GLES/ShaderManagerGLES.cpp b/GPU/GLES/ShaderManagerGLES.cpp index ccf15e9268..6868b5d988 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 }); @@ -993,7 +995,7 @@ void ShaderManagerGLES::Load(const Path &filename) { if (!f.ReadArray(&fsid, 1)) { return; } - diskCachePending_.link.push_back(std::make_pair(vsid, fsid)); + diskCachePending_.link.emplace_back(vsid, fsid); } // Actual compilation happens in ContinuePrecompile(), called by GPU_GLES's IsReady. 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/CwCheatScreen.cpp b/UI/CwCheatScreen.cpp index 8b4ba9d146..dee7a11166 100644 --- a/UI/CwCheatScreen.cpp +++ b/UI/CwCheatScreen.cpp @@ -199,7 +199,6 @@ UI::EventReturn CwCheatScreen::OnImportCheat(UI::EventParams ¶ms) { WARN_LOG(COMMON, "CWCHEAT: Incorrect ID(%s) - can't import cheats.", gameID_.c_str()); return UI::EVENT_DONE; } - std::string line; std::vector title; std::vector newList; diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index baa795351f..c29d8e67c6 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -1058,7 +1058,7 @@ void EmuScreen::update() { errLoadingFile.append(err->T(errorMessage_.c_str())); screenManager()->push(new PromptScreen(errLoadingFile, "OK", "")); - errorMessage_ = ""; + errorMessage_.clear(); quit_ = true; return; } diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 876db2773e..4d1d6c6798 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); } @@ -1231,7 +1231,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; } @@ -1497,7 +1497,7 @@ void GameSettingsScreen::TriggerRestart(const char *why) { std::string param = "--gamesettings"; if (editThenRestore_) { // We won't pass the gameID, so don't resume back into settings. - param = ""; + param.clear(); } else if (!gamePath_.empty()) { param += " \"" + ReplaceAll(ReplaceAll(gamePath_.ToString(), "\\", "\\\\"), "\"", "\\\"") + "\""; } 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/Store.cpp b/UI/Store.cpp index 8329ed22d9..86a084da95 100644 --- a/UI/Store.cpp +++ b/UI/Store.cpp @@ -502,7 +502,7 @@ void StoreScreen::CreateViews() { selectedItem->Press(); } else { - lastSelectedName_ = ""; + lastSelectedName_.clear(); } } root_->Add(content); diff --git a/UI/TextureUtil.cpp b/UI/TextureUtil.cpp index 9a5b377a90..80dfb59e1a 100644 --- a/UI/TextureUtil.cpp +++ b/UI/TextureUtil.cpp @@ -151,7 +151,7 @@ bool ManagedTexture::LoadFromFile(const std::string &filename, ImageFileType typ size_t fileSize; uint8_t *buffer = VFSReadFile(filename.c_str(), &fileSize); if (!buffer) { - filename_ = ""; + filename_.clear(); ERROR_LOG(IO, "Failed to read file '%s'", filename.c_str()); return false; } @@ -159,7 +159,7 @@ bool ManagedTexture::LoadFromFile(const std::string &filename, ImageFileType typ if (retval) { filename_ = filename; } else { - filename_ = ""; + filename_.clear(); ERROR_LOG(IO, "Failed to load texture '%s'", filename.c_str()); } delete[] buffer; 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/CtrlDisAsmView.cpp b/Windows/Debugger/CtrlDisAsmView.cpp index 88e5ad28ff..7faf3b6f2b 100644 --- a/Windows/Debugger/CtrlDisAsmView.cpp +++ b/Windows/Debugger/CtrlDisAsmView.cpp @@ -191,7 +191,7 @@ CtrlDisAsmView::CtrlDisAsmView(HWND _wnd) matchAddress = -1; searching = false; - searchQuery = ""; + searchQuery.clear(); windowStart = curAddress; whiteBackground = false; displaySymbols = true; diff --git a/Windows/Debugger/CtrlMemView.cpp b/Windows/Debugger/CtrlMemView.cpp index c8f8a3f8df..d40bdaf483 100644 --- a/Windows/Debugger/CtrlMemView.cpp +++ b/Windows/Debugger/CtrlMemView.cpp @@ -49,7 +49,7 @@ CtrlMemView::CtrlMemView(HWND _wnd) curAddress = 0; debugger = 0; - searchQuery = ""; + searchQuery.clear(); matchAddress = -1; searching = false; @@ -767,10 +767,11 @@ std::vector CtrlMemView::searchString(const std::string &searchQuery) { return searchResAddrs; std::vector> memoryAreas; - memoryAreas.push_back(std::pair(PSP_GetScratchpadMemoryBase(), PSP_GetScratchpadMemoryEnd())); + memoryAreas.reserve(3); + memoryAreas.emplace_back(PSP_GetScratchpadMemoryBase(), PSP_GetScratchpadMemoryEnd()); // Ignore the video memory mirrors. - memoryAreas.push_back(std::pair(PSP_GetVidMemBase(), 0x04200000)); - memoryAreas.push_back(std::pair(PSP_GetKernelMemoryBase(), PSP_GetUserMemoryEnd())); + memoryAreas.emplace_back(PSP_GetVidMemBase(), 0x04200000); + memoryAreas.emplace_back(PSP_GetKernelMemoryBase(), PSP_GetUserMemoryEnd()); for (const auto &area : memoryAreas) { const u32 segmentStart = area.first; @@ -821,10 +822,11 @@ 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())); - memoryAreas.push_back(std::pair(PSP_GetScratchpadMemoryBase(), PSP_GetScratchpadMemoryEnd())); + memoryAreas.emplace_back(PSP_GetVidMemBase(), 0x04200000); + memoryAreas.emplace_back(PSP_GetKernelMemoryBase(), PSP_GetUserMemoryEnd()); + memoryAreas.emplace_back(PSP_GetScratchpadMemoryBase(), PSP_GetScratchpadMemoryEnd()); searching = true; redraw(); // so the cursor is disabled 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/InputBox.cpp b/Windows/InputBox.cpp index 1d4fd02e7e..632a8134fe 100644 --- a/Windows/InputBox.cpp +++ b/Windows/InputBox.cpp @@ -49,12 +49,12 @@ bool InputBox_GetString(HINSTANCE hInst, HWND hParent, const wchar_t *title, con if (defaultValue.size() < 255) textBoxContents = ConvertUTF8ToWString(defaultValue); else - textBoxContents = L""; + textBoxContents.clear(); if (title != NULL) windowTitle = title; else - windowTitle = L""; + windowTitle.clear(); if (IDOK == DialogBox(hInst, (LPCWSTR)IDD_INPUTBOX, hParent, InputBoxFunc)) { outvalue = ConvertWStringToUTF8(out); diff --git a/Windows/MainWindowMenu.cpp b/Windows/MainWindowMenu.cpp index 6aba9d275a..384bb9a0f7 100644 --- a/Windows/MainWindowMenu.cpp +++ b/Windows/MainWindowMenu.cpp @@ -911,7 +911,7 @@ namespace MainWindow { if (lastSlash) { fn = lastSlash + 1; } else { - fn = ""; + fn.clear(); } PSPFileInfo info = pspFileSystem.GetFileInfo(filename); diff --git a/Windows/W32Util/ShellUtil.cpp b/Windows/W32Util/ShellUtil.cpp index c6d3a2bc49..bd53935d27 100644 --- a/Windows/W32Util/ShellUtil.cpp +++ b/Windows/W32Util/ShellUtil.cpp @@ -144,7 +144,7 @@ namespace W32Util files.push_back(directory); } else { while (*temp) { - files.push_back(directory + "\\" + ConvertWStringToUTF8(temp)); + files.emplace_back(directory + "\\" + ConvertWStringToUTF8(temp)); temp += wcslen(temp) + 1; } } @@ -199,7 +199,7 @@ namespace W32Util switch (type_) { case DIR: filename_ = BrowseForFolder(parent_, title_.c_str()); - result_ = filename_ != ""; + result_ = !filename_.empty(); complete_ = true; break; diff --git a/Windows/main.cpp b/Windows/main.cpp index e3888dfe4c..90e216f283 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -211,7 +211,7 @@ std::string System_GetProperty(SystemProperty prop) { if (wstr) retval = ConvertWStringToUTF8(wstr); else - retval = ""; + retval.clear(); GlobalUnlock(handle); CloseClipboard(); } diff --git a/android/jni/TestRunner.cpp b/android/jni/TestRunner.cpp index d032a9db75..64e6f7761c 100644 --- a/android/jni/TestRunner.cpp +++ b/android/jni/TestRunner.cpp @@ -107,7 +107,7 @@ bool RunTests() { // Never report from tests. std::string savedReportHost = g_Config.sReportHost; - g_Config.sReportHost = ""; + g_Config.sReportHost.clear(); for (size_t i = 0; i < ARRAY_SIZE(testsToRun); i++) { std::string testName = testsToRun[i]; @@ -116,7 +116,7 @@ bool RunTests() { INFO_LOG(SYSTEM, "Preparing to execute '%s'", testName.c_str()); std::string error_string; - output = ""; + output.clear(); if (!PSP_Init(coreParam, &error_string)) { ERROR_LOG(SYSTEM, "Failed to init unittest %s : %s", testsToRun[i], error_string.c_str()); PSP_CoreParameter().pixelWidth = pixel_xres; diff --git a/headless/Headless.cpp b/headless/Headless.cpp index 1deebd95cd..dcfad07e8d 100644 --- a/headless/Headless.cpp +++ b/headless/Headless.cpp @@ -411,7 +411,7 @@ int main(int argc, const char* argv[]) g_Config.bFirstRun = false; g_Config.bIgnoreBadMemAccess = true; // Never report from tests. - g_Config.sReportHost = ""; + g_Config.sReportHost.clear(); g_Config.bAutoSaveSymbolMap = false; g_Config.iRenderingMode = FB_BUFFERED_MODE; g_Config.bHardwareTransform = true; diff --git a/unittest/UnitTest.cpp b/unittest/UnitTest.cpp index 4f8239a11b..bb3d9d112b 100644 --- a/unittest/UnitTest.cpp +++ b/unittest/UnitTest.cpp @@ -634,7 +634,7 @@ static bool TestPath() { Path path3 = path2 / "foo/bar"; EXPECT_EQ_STR(path3.WithExtraExtension(".txt").ToString(), std::string("/asdf/jkl/foo/bar.txt")); - EXPECT_EQ_STR(Path("foo.bar/hello").GetFileExtension(), std::string("")); + EXPECT_EQ_STR(Path("foo.bar/hello").GetFileExtension(), std::string()); EXPECT_EQ_STR(Path("foo.bar/hello.txt").WithReplacedExtension(".txt", ".html").ToString(), std::string("foo.bar/hello.html")); EXPECT_EQ_STR(Path("C:\\Yo").NavigateUp().ToString(), std::string("C:"));