Parallelize game db scanning so games don't take ages to boot

This commit is contained in:
SimoneN64
2023-06-09 09:44:38 +02:00
parent 19a99e6516
commit 041dff5ee0

View File

@@ -1,10 +1,12 @@
#include <GameDB.hpp> #include <GameDB.hpp>
#include <Mem.hpp> #include <Mem.hpp>
#include <algorithm>
#include <execution>
namespace n64 { namespace n64 {
void GameDB::match(Mem& mem) { void GameDB::match(Mem& mem) {
ROM& rom = mem.rom; ROM& rom = mem.rom;
for (const auto & i : gamedb) { std::for_each(std::execution::par, std::begin(gamedb), std::end(gamedb), [&](const auto& i) {
bool matches_code = i.code == rom.code; bool matches_code = i.code == rom.code;
bool matches_region = false; bool matches_region = false;
@@ -24,7 +26,7 @@ void GameDB::match(Mem& mem) {
i.name, i.regions, rom.header.countryCode[0]); i.name, i.regions, rom.header.countryCode[0]);
} }
} }
} });
Util::debug("Did not match any Game DB entries. Code: {} Region: {}", mem.rom.code, mem.rom.header.countryCode[0]); Util::debug("Did not match any Game DB entries. Code: {} Region: {}", mem.rom.code, mem.rom.header.countryCode[0]);