diff --git a/Source/Core/Core/GeckoCode.cpp b/Source/Core/Core/GeckoCode.cpp index 023bceac46..cfb9e35a70 100644 --- a/Source/Core/Core/GeckoCode.cpp +++ b/Source/Core/Core/GeckoCode.cpp @@ -7,24 +7,22 @@ #include "Thread.h" #include "HW/Memmap.h" #include "ConfigManager.h" - -#include "vector" #include "PowerPC/PowerPC.h" #include "CommonPaths.h" +#include + namespace Gecko { // return true if a code exists bool GeckoCode::Exist(u32 address, u32 data) { - std::vector::const_iterator - codes_iter = codes.begin(), - codes_end = codes.end(); - for (; codes_iter != codes_end; ++codes_iter) + for (const GeckoCode::Code& code : codes) { - if (codes_iter->address == address && codes_iter->data == data) + if (code.address == address && code.data == data) return true; } + return false; } @@ -35,14 +33,13 @@ bool GeckoCode::Compare(GeckoCode compare) const return false; unsigned int exist = 0; - std::vector::const_iterator - codes_iter = codes.begin(), - codes_end = codes.end(); - for (; codes_iter != codes_end; ++codes_iter) + + for (const GeckoCode::Code& code : codes) { - if (compare.Exist(codes_iter->address, codes_iter->data)) + if (compare.Exist(code.address, code.data)) exist++; } + return exist == codes.size(); } @@ -56,17 +53,15 @@ void SetActiveCodes(const std::vector& gcodes) std::lock_guard lk(active_codes_lock); active_codes.clear(); + // add enabled codes - std::vector::const_iterator - gcodes_iter = gcodes.begin(), - gcodes_end = gcodes.end(); - for (; gcodes_iter!=gcodes_end; ++gcodes_iter) + for (const GeckoCode& gecko_code : gcodes) { - if (gcodes_iter->enabled) + if (gecko_code.enabled) { // TODO: apply modifiers // TODO: don't need description or creator string, just takin up memory - active_codes.push_back(*gcodes_iter); + active_codes.push_back(gecko_code); } } @@ -101,14 +96,12 @@ bool InstallCodeHandler() std::lock_guard lk(active_codes_lock); int i = 0; - std::vector::iterator - gcodes_iter = active_codes.begin(), - gcodes_end = active_codes.end(); - for (; gcodes_iter!=gcodes_end; ++gcodes_iter) + + for (const GeckoCode& active_code : active_codes) { - if (gcodes_iter->enabled) + if (active_code.enabled) { - for (auto& code : gcodes_iter->codes) + for (const GeckoCode::Code& code : active_code.codes) { // Make sure we have enough memory to hold the code list if ((codelist_location + 24 + i) < 0x80003000) diff --git a/Source/Core/Core/GeckoCode.h b/Source/Core/Core/GeckoCode.h index 5bd3814e66..ec027dcd9d 100644 --- a/Source/Core/Core/GeckoCode.h +++ b/Source/Core/Core/GeckoCode.h @@ -31,9 +31,9 @@ namespace Gecko u32 GetAddress() const; }; - std::vector codes; - std::string name, creator; - std::vector notes; + std::vector codes; + std::string name, creator; + std::vector notes; bool enabled; bool user_defined; diff --git a/Source/Core/Core/GeckoCodeConfig.cpp b/Source/Core/Core/GeckoCodeConfig.cpp index b6059ef090..e5e64968f5 100644 --- a/Source/Core/Core/GeckoCodeConfig.cpp +++ b/Source/Core/Core/GeckoCodeConfig.cpp @@ -115,23 +115,17 @@ void SaveGeckoCode(std::vector& lines, std::vector& en lines.push_back(name); // save all the code lines - std::vector::const_iterator - codes_iter = gcode.codes.begin(), - codes_end = gcode.codes.end(); - for (; codes_iter!=codes_end; ++codes_iter) + for (const GeckoCode::Code& code : gcode.codes) { //ss << std::hex << codes_iter->address << ' ' << codes_iter->data; //lines.push_back(StringFromFormat("%08X %08X", codes_iter->address, codes_iter->data)); - lines.push_back(codes_iter->original_line); + lines.push_back(code.original_line); //ss.clear(); } // save the notes - std::vector::const_iterator - notes_iter = gcode.notes.begin(), - notes_end = gcode.notes.end(); - for (; notes_iter!=notes_end; ++notes_iter) - lines.push_back(std::string("*") + *notes_iter); + for (const std::string& note : gcode.notes) + lines.push_back(std::string("*") + note); } void SaveCodes(IniFile& inifile, const std::vector& gcodes) @@ -139,12 +133,9 @@ void SaveCodes(IniFile& inifile, const std::vector& gcodes) std::vector lines; std::vector enabledLines; - std::vector::const_iterator - gcodes_iter = gcodes.begin(), - gcodes_end = gcodes.end(); - for (; gcodes_iter!=gcodes_end; ++gcodes_iter) + for (const GeckoCode& geckoCode : gcodes) { - SaveGeckoCode(lines, enabledLines, *gcodes_iter); + SaveGeckoCode(lines, enabledLines, geckoCode); } inifile.SetLines("Gecko", lines);