Fix some bad "for (auto x : y)" usage

This commit is contained in:
Henrik Rydgård committed 2025-04-29 16:46:14 +02:00
1 parent 62e4b2852c
commit dbe6ec80a0
17 files changed
+31 -27

No files matched your search

+3 -3
View File
@@ -36,7 +36,7 @@ bool JsonReader::parse() {
int JsonGet::numChildren() const {
int count = 0;
if (value_.getTag() == JSON_OBJECT || value_.getTag() == JSON_ARRAY) {
for (auto it : value_) {
for (const auto &it : value_) {
(void)it;
count++;
}
@@ -52,7 +52,7 @@ const JsonNode *JsonGet::get(const char *child_name) const {
if (value_.getTag() != JSON_OBJECT) {
return nullptr;
}
for (auto it : value_) {
for (const auto &it : value_) {
if (!strcmp(it->key, child_name)) {
return it;
}
@@ -94,7 +94,7 @@ const char *JsonGet::getStringOr(const char *child_name, const char *default_val
bool JsonGet::getStringVector(std::vector<std::string> *vec) const {
vec->clear();
if (value_.getTag() == JSON_ARRAY) {
for (auto it : value_) {
for (const auto &it : value_) {
if (it->value.getTag() == JSON_STRING) {
vec->push_back(it->value.toString());
}
+2 -2
View File
@@ -198,7 +198,7 @@ void GLQueueRunner::RunInitSteps(const FastVec<GLRInitStep> &steps, bool skipGLC
glAttachShader(program->program, step.create_program.shaders[j]->shader);
}
for (auto iter : program->semantics_) {
for (const auto &iter : program->semantics_) {
glBindAttribLocation(program->program, iter.location, iter.attrib);
}
@@ -304,7 +304,7 @@ void GLQueueRunner::RunInitSteps(const FastVec<GLRInitStep> &steps, bool skipGLC
LineNumberString(code).c_str());
std::vector<std::string_view> lines;
SplitString(errorString, '\n', lines);
for (auto line : lines) {
for (const auto &line : lines) {
ERROR_LOG(Log::G3D, "%.*s", (int)line.size(), line.data());
}
if (errorCallback_) {
+1 -1
View File
@@ -507,7 +507,7 @@ void VulkanRenderManager::CompileThreadFunc() {
}
}
for (auto iter : map) {
for (const auto &iter : map) {
auto &shaders = iter.first;
auto &entries = iter.second;
+1 -1
View File
@@ -528,7 +528,7 @@ const UniformBufferDesc vsTexColBufDesc{ sizeof(VsTexColUB),{
ShaderModule *CreateShader(DrawContext *draw, ShaderStage stage, const std::vector<ShaderSource> &sources) {
uint32_t supported = draw->GetSupportedShaderLanguages();
for (auto iter : sources) {
for (const auto &iter : sources) {
if ((uint32_t)iter.lang & supported) {
return draw->CreateShaderModule(stage, iter.lang, (const uint8_t *)iter.src, strlen(iter.src));
}
+1 -1
View File
@@ -160,7 +160,7 @@ std::shared_ptr<Request> RequestManager::AsyncPostWithCallback(
}
void RequestManager::Update() {
for (auto iter : newDownloads_) {
for (auto &iter : newDownloads_) {
downloads_.push_back(iter);
}
newDownloads_.clear();
+1 -1
View File
@@ -116,7 +116,7 @@ void CachingFileLoader::ShutdownCache() {
aheadThread_.join();
std::lock_guard<std::recursive_mutex> guard(blocksMutex_);
for (auto block : blocks_) {
for (const auto &block : blocks_) {
delete [] block.second.ptr;
}
blocks_.clear();
+1 -1
View File
@@ -129,7 +129,7 @@ std::vector<Path> DiskCachingFileLoader::GetCachedPathsInUse() {
std::vector<Path> files;
files.reserve(caches_.size());
for (auto it : caches_) {
for (const auto &it : caches_) {
files.push_back(it.first);
}
+1 -1
View File
@@ -646,7 +646,7 @@ void MetaFileSystem::DoState(PointerWrap &p) {
int64_t MetaFileSystem::RecursiveSize(const std::string &dirPath) {
u64 result = 0;
auto allFiles = GetDirListing(dirPath);
for (auto file : allFiles) {
for (const auto &file : allFiles) {
if (file.name == "." || file.name == "..")
continue;
if (file.type == FILETYPE_DIRECTORY) {
+1 -1
View File
@@ -742,7 +742,7 @@ public:
private:
int FindExistingIndex(Font *font) const {
// TODO: Should this also match for memory fonts, or only internal fonts?
for (auto it : fontMap) {
for (const auto &it : fontMap) {
if (it.second->GetFont() != font || it.second->GetFontLib() != this)
continue;
for (size_t i = 0; i < fonts_.size(); i++) {
+1 -1
View File
@@ -75,7 +75,7 @@ void __HeapInit() {
}
void __HeapShutdown() {
for (auto it : heapList) {
for (const auto &it : heapList) {
delete it.second;
}
heapList.clear();
+1 -1
View File
@@ -542,7 +542,7 @@ static void WriteVarSymbol(WriteVarSymbolState &state, u32 exportAddress, u32 re
ERROR_LOG_REPORT(Log::Loader, "HI16 and LO16 imports do not match at %08x for %08x (should be %08x)", relocAddress, state.lastHI16ExportAddress, exportAddress);
} else {
// Process each of the HI16. Usually there's only one.
for (auto &reloc : state.lastHI16Relocs) {
for (const auto &reloc : state.lastHI16Relocs) {
if (!reverse) {
full = (reloc.data << 16) + offsetLo + exportAddress;
} else {
+2 -2
View File
@@ -119,7 +119,7 @@ std::string InfraDNSConfig::ToString() const {
}
if (!fixedDNS.empty()) {
w.C("Fixed DNS").endl();
for (auto iter : fixedDNS) {
for (const auto &iter : fixedDNS) {
w.F("%s -> %s", iter.first.c_str(), iter.second.c_str()).endl();
}
}
@@ -290,7 +290,7 @@ bool LoadDNSForGameID(std::string_view gameID, std::string_view jsonStr, InfraDN
dns->connectAdHocForGrouping = game.getBool("connect_adhoc_for_grouping", dns->connectAdHocForGrouping);
if (game.hasChild("domains", JSON_OBJECT)) {
const JsonGet domains = game.getDict("domains");
for (auto iter : domains.value_) {
for (const auto &iter : domains.value_) {
std::string domain = std::string(iter->key);
std::string ipAddr = std::string(iter->value.toString());
dns->fixedDNS[domain] = ipAddr;
+3 -3
View File
@@ -594,7 +594,7 @@ bool Psmf::setStreamNum(u32 psmfStruct, int num, bool updateCached) {
}
bool Psmf::setStreamWithType(u32 psmfStruct, int type, int channel) {
for (auto iter : streamMap) {
for (const auto &iter : streamMap) {
// Note: this does NOT support PSMF_AUDIO_STREAM.
if (iter.second->type_ == type && iter.second->channel_ == channel) {
return setStreamNum(psmfStruct, iter.first);
@@ -604,7 +604,7 @@ bool Psmf::setStreamWithType(u32 psmfStruct, int type, int channel) {
}
bool Psmf::setStreamWithTypeNumber(u32 psmfStruct, int type, int n) {
for (auto iter : streamMap) {
for (const auto &iter : streamMap) {
if (iter.second->matchesType(type)) {
if (n != 0) {
// Keep counting...
@@ -797,7 +797,7 @@ static u32 scePsmfGetNumberOfSpecificStreams(u32 psmfStruct, int streamType) {
}
int streamNum = 0;
for (auto it : psmf->streamMap) {
for (const auto &it : psmf->streamMap) {
if (it.second->matchesType(streamType)) {
streamNum++;
}
+2 -2
View File
@@ -356,7 +356,7 @@ void MediaEngine::closeContext()
av_free(m_pIOContext->buffer);
if (m_pIOContext)
av_free(m_pIOContext);
for (auto it : m_pCodecCtxs) {
for (const auto &it : m_pCodecCtxs) {
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(57, 33, 100)
avcodec_free_context(&it.second);
#else
@@ -365,7 +365,7 @@ void MediaEngine::closeContext()
}
m_pCodecCtxs.clear();
// These are streams allocated from avformat_new_stream.
for (auto it : m_codecsToClose) {
for (const auto &it : m_codecsToClose) {
avcodec_close(it);
}
m_codecsToClose.clear();
+1 -1
View File
@@ -303,7 +303,7 @@ void X64JitBackend::GenerateFixedCode(MIPSState *mipsState) {
if (enableDisasm) {
#if PPSSPP_ARCH(AMD64)
std::vector<std::string> lines = DisassembleX86(disasmStart, (int)(GetCodePtr() - disasmStart));
for (auto s : lines) {
for (const auto &s : lines) {
INFO_LOG(Log::JIT, "%s", s.c_str());
}
#endif
+1 -1
View File
@@ -589,7 +589,7 @@ BootState PSP_InitUpdate(std::string *error_string) {
_dbg_assert_(g_bootState == BootState::Complete || g_bootState == BootState::Failed);
// Since we load on a background thread, wait for startup to complete.
_dbg_assert_(g_loadingThread.joinable());
_assert_msg_(g_loadingThread.joinable(), "bootstate: %d", (int)g_bootState);
g_loadingThread.join();
if (g_bootState == BootState::Failed) {
+8 -4
View File
@@ -345,8 +345,10 @@ void EmuScreen::ProcessGameBoot(const Path &filename) {
return;
}
loadingViewColor_->Divert(0xFFFFFFFF, 0.75f);
loadingViewVisible_->Divert(UI::V_VISIBLE, 0.75f);
if (loadingViewColor_)
loadingViewColor_->Divert(0xFFFFFFFF, 0.75f);
if (loadingViewVisible_)
loadingViewVisible_->Divert(UI::V_VISIBLE, 0.75f);
screenManager()->getDrawContext()->ResetStats();
@@ -431,8 +433,10 @@ void EmuScreen::bootComplete() {
saveStateSlot_ = SaveState::GetCurrentSlot();
loadingViewColor_->Divert(0x00FFFFFF, 0.2f);
loadingViewVisible_->Divert(UI::V_INVISIBLE, 0.2f);
if (loadingViewColor_)
loadingViewColor_->Divert(0x00FFFFFF, 0.2f);
if (loadingViewVisible_)
loadingViewVisible_->Divert(UI::V_INVISIBLE, 0.2f);
std::string gameID = g_paramSFO.GetValueString("DISC_ID");
g_Config.TimeTracker().Start(gameID);