Using const reference for C++17 range-based loop and freq used objects

This commit is contained in:
Herman Semenov 2023-12-12 17:38:50 +03:00 committed by Henrik Rydgård
parent da318e0974
commit 315340fc62
13 changed files with 20 additions and 20 deletions

View file

@ -426,7 +426,7 @@ void CPUInfo::Detect() {
if (GetLogicalProcessorInformation(&processors[0], &len)) { if (GetLogicalProcessorInformation(&processors[0], &len)) {
num_cores = 0; num_cores = 0;
logical_cpu_count = 0; logical_cpu_count = 0;
for (auto processor : processors) { for (const auto &processor : processors) {
if (processor.Relationship == RelationProcessorCore) { if (processor.Relationship == RelationProcessorCore) {
num_cores++; num_cores++;
for (int i = 0; i < sizeof(processor.ProcessorMask) * 8; ++i) { for (int i = 0; i < sizeof(processor.ProcessorMask) * 8; ++i) {

View file

@ -404,7 +404,7 @@ bool VulkanMayBeAvailable() {
ERROR_LOG(G3D, "Enumerating VK extensions failed (%s)", VulkanResultToString(res)); ERROR_LOG(G3D, "Enumerating VK extensions failed (%s)", VulkanResultToString(res));
goto bail; goto bail;
} }
for (auto iter : instanceExts) { for (const auto &iter : instanceExts) {
INFO_LOG(G3D, "VulkanMaybeAvailable: Instance extension found: %s (%08x)", iter.extensionName, iter.specVersion); INFO_LOG(G3D, "VulkanMaybeAvailable: Instance extension found: %s (%08x)", iter.extensionName, iter.specVersion);
if (platformSurfaceExtension && !strcmp(iter.extensionName, platformSurfaceExtension)) { if (platformSurfaceExtension && !strcmp(iter.extensionName, platformSurfaceExtension)) {
INFO_LOG(G3D, "VulkanMayBeAvailable: Found platform surface extension '%s'", platformSurfaceExtension); INFO_LOG(G3D, "VulkanMayBeAvailable: Found platform surface extension '%s'", platformSurfaceExtension);

View file

@ -259,10 +259,10 @@ void ScreenManager::sendMessage(UIMessage message, const char *value) {
void ScreenManager::shutdown() { void ScreenManager::shutdown() {
std::lock_guard<std::recursive_mutex> guard(inputLock_); std::lock_guard<std::recursive_mutex> guard(inputLock_);
for (auto layer : stack_) for (const auto &layer : stack_)
delete layer.screen; delete layer.screen;
stack_.clear(); stack_.clear();
for (auto layer : nextStack_) for (const auto &layer : nextStack_)
delete layer.screen; delete layer.screen;
nextStack_.clear(); nextStack_.clear();
delete overlayScreen_; delete overlayScreen_;

View file

@ -68,7 +68,7 @@ void WebSocketHLEThreadList(DebuggerRequest &req) {
JsonWriter &json = req.Respond(); JsonWriter &json = req.Respond();
json.pushArray("threads"); json.pushArray("threads");
for (auto th : threads) { for (const auto &th : threads) {
json.pushDict(); json.pushDict();
json.writeUint("id", th.id); json.writeUint("id", th.id);
json.writeString("name", th.name); json.writeString("name", th.name);
@ -114,7 +114,7 @@ static bool ThreadInfoForStatus(DebuggerRequest &req, DebugThreadInfo *result) {
return false; return false;
auto threads = GetThreadsInfo(); auto threads = GetThreadsInfo();
for (auto t : threads) { for (const auto &t : threads) {
if (t.id == threadID) { if (t.id == threadID) {
*result = t; *result = t;
return true; return true;

View file

@ -880,7 +880,7 @@ std::set<std::string> SavedataParam::GetSecureFileNames(const std::string &dirPa
auto entries = GetSFOEntries(dirPath); auto entries = GetSFOEntries(dirPath);
std::set<std::string> secureFileNames; std::set<std::string> secureFileNames;
for (auto entry : entries) { for (const auto &entry : entries) {
char temp[14]; char temp[14];
truncate_cpy(temp, entry.filename); truncate_cpy(temp, entry.filename);
secureFileNames.insert(temp); secureFileNames.insert(temp);

View file

@ -1192,7 +1192,7 @@ static int sceFontFindOptimumFont(u32 libHandle, u32 fontStylePtr, u32 errorCode
for (size_t i = 0; i < internalFonts.size(); i++) { for (size_t i = 0; i < internalFonts.size(); i++) {
MatchQuality q = internalFonts[i]->MatchesStyle(*requestedStyle); MatchQuality q = internalFonts[i]->MatchesStyle(*requestedStyle);
if (q != MATCH_NONE) { if (q != MATCH_NONE) {
auto matchStyle = internalFonts[i]->GetFontStyle(); const auto &matchStyle = internalFonts[i]->GetFontStyle();
if (requestedStyle->fontH > 0.0f) { if (requestedStyle->fontH > 0.0f) {
float hDist = fabs(matchStyle.fontHRes * matchStyle.fontH - hRes * requestedStyle->fontH); float hDist = fabs(matchStyle.fontHRes * matchStyle.fontH - hRes * requestedStyle->fontH);
if (hDist < nearestDist) { if (hDist < nearestDist) {
@ -1255,7 +1255,7 @@ static int sceFontFindFont(u32 libHandle, u32 fontStylePtr, u32 errorCodePtr) {
float hRes = requestedStyle->fontHRes > 0.0f ? (float)requestedStyle->fontHRes : fontLib->FontHRes(); float hRes = requestedStyle->fontHRes > 0.0f ? (float)requestedStyle->fontHRes : fontLib->FontHRes();
for (size_t i = 0; i < internalFonts.size(); i++) { for (size_t i = 0; i < internalFonts.size(); i++) {
if (internalFonts[i]->MatchesStyle(*requestedStyle) != MATCH_NONE) { if (internalFonts[i]->MatchesStyle(*requestedStyle) != MATCH_NONE) {
auto matchStyle = internalFonts[i]->GetFontStyle(); const auto &matchStyle = internalFonts[i]->GetFontStyle();
if (requestedStyle->fontH > 0.0f) { if (requestedStyle->fontH > 0.0f) {
float hDist = fabs(matchStyle.fontHRes * matchStyle.fontH - hRes * requestedStyle->fontH); float hDist = fabs(matchStyle.fontHRes * matchStyle.fontH - hRes * requestedStyle->fontH);
if (hDist > 0.001f) { if (hDist > 0.001f) {

View file

@ -354,7 +354,7 @@ public:
bool foundBroken = false; bool foundBroken = false;
auto importedFuncsState = importedFuncs; auto importedFuncsState = importedFuncs;
importedFuncs.clear(); importedFuncs.clear();
for (auto func : importedFuncsState) { for (const auto &func : importedFuncsState) {
if (func.moduleName[KERNELOBJECT_MAX_NAME_LENGTH] != '\0' || !Memory::IsValidAddress(func.stubAddr)) { if (func.moduleName[KERNELOBJECT_MAX_NAME_LENGTH] != '\0' || !Memory::IsValidAddress(func.stubAddr)) {
foundBroken = true; foundBroken = true;
} else { } else {

View file

@ -291,8 +291,8 @@ std::vector<const ShaderInfo *> GetPostShaderChain(const std::string &name) {
std::vector<const ShaderInfo *> GetFullPostShadersChain(const std::vector<std::string> &names) { std::vector<const ShaderInfo *> GetFullPostShadersChain(const std::vector<std::string> &names) {
std::vector<const ShaderInfo *> fullChain; std::vector<const ShaderInfo *> fullChain;
for (auto shaderName : names) { for (const auto &shaderName : names) {
auto shaderChain = GetPostShaderChain(shaderName); const auto &shaderChain = GetPostShaderChain(shaderName);
fullChain.insert(fullChain.end(), shaderChain.begin(), shaderChain.end()); fullChain.insert(fullChain.end(), shaderChain.begin(), shaderChain.end());
} }
return fullChain; return fullChain;

View file

@ -1501,7 +1501,7 @@ std::string VertexDecoder::GetString(DebugShaderStringType stringType) {
// No disassembler defined // No disassembler defined
#endif #endif
std::string buffer; std::string buffer;
for (auto line : lines) { for (const auto &line : lines) {
buffer += line; buffer += line;
buffer += "\n"; buffer += "\n";
} }

View file

@ -1192,7 +1192,7 @@ void ShaderManagerGLES::SaveCache(const Path &filename, DrawEngineGLES *drawEngi
fsCache_.Iterate([&](const ShaderID &id, Shader *shader) { fsCache_.Iterate([&](const ShaderID &id, Shader *shader) {
fwrite(&id, 1, sizeof(id), f); fwrite(&id, 1, sizeof(id), f);
}); });
for (auto iter : linkedShaderCache_) { for (const auto &iter : linkedShaderCache_) {
ShaderID vsid, fsid; ShaderID vsid, fsid;
vsCache_.Iterate([&](const ShaderID &id, Shader *shader) { vsCache_.Iterate([&](const ShaderID &id, Shader *shader) {
if (iter.vs == shader) if (iter.vs == shader)

View file

@ -1114,17 +1114,17 @@ void JitCompareScreen::UpdateDisasm() {
// Alright. First generate the MIPS disassembly. // Alright. First generate the MIPS disassembly.
// TODO: Need a way to communicate branch continuing. // TODO: Need a way to communicate branch continuing.
for (auto line : debugInfo.origDisasm) { for (const auto &line : debugInfo.origDisasm) {
leftDisasm_->Add(new TextView(line))->SetFocusable(true); leftDisasm_->Add(new TextView(line))->SetFocusable(true);
} }
// TODO : When we have both target and IR, need a third column. // TODO : When we have both target and IR, need a third column.
if (debugInfo.targetDisasm.size()) { if (debugInfo.targetDisasm.size()) {
for (auto line : debugInfo.targetDisasm) { for (const auto &line : debugInfo.targetDisasm) {
rightDisasm_->Add(new TextView(line))->SetFocusable(true); rightDisasm_->Add(new TextView(line))->SetFocusable(true);
} }
} else { } else {
for (auto line : debugInfo.irDisasm) { for (const auto &line : debugInfo.irDisasm) {
rightDisasm_->Add(new TextView(line))->SetFocusable(true); rightDisasm_->Add(new TextView(line))->SetFocusable(true);
} }
} }
@ -1377,7 +1377,7 @@ void ShaderViewScreen::CreateViews() {
std::vector<std::string> lines; std::vector<std::string> lines;
SplitString(gpu->DebugGetShaderString(id_, type_, SHADER_STRING_SOURCE_CODE), '\n', lines); SplitString(gpu->DebugGetShaderString(id_, type_, SHADER_STRING_SOURCE_CODE), '\n', lines);
for (auto line : lines) { for (const auto &line : lines) {
lineLayout->Add(new TextView(line, FLAG_DYNAMIC_ASCII | FLAG_WRAP_TEXT, true)); lineLayout->Add(new TextView(line, FLAG_DYNAMIC_ASCII | FLAG_WRAP_TEXT, true));
} }

View file

@ -511,7 +511,7 @@ bool GameScreen::isRecentGame(const Path &gamePath) {
return false; return false;
const std::string resolved = File::ResolvePath(gamePath.ToString()); const std::string resolved = File::ResolvePath(gamePath.ToString());
for (auto iso : g_Config.RecentIsos()) { for (const auto &iso : g_Config.RecentIsos()) {
const std::string recent = File::ResolvePath(iso); const std::string recent = File::ResolvePath(iso);
if (resolved == recent) if (resolved == recent)
return true; return true;

View file

@ -485,7 +485,7 @@ void ReportFinishScreen::ShowSuggestions() {
resultItems_->Clear(); resultItems_->Clear();
bool shownConfig = false; bool shownConfig = false;
bool valid = false; bool valid = false;
for (auto item : suggestions) { for (const auto &item : suggestions) {
const char *suggestion = nullptr; const char *suggestion = nullptr;
if (item == "Upgrade") { if (item == "Upgrade") {
suggestion = rp->T("SuggestionUpgrade", "Upgrade to a newer PPSSPP build"); suggestion = rp->T("SuggestionUpgrade", "Upgrade to a newer PPSSPP build");