Integrate GotoNextGame() for better efficiency

This commit is contained in:
Loic Guegan 2023-01-20 10:08:10 +01:00
parent 1eca34d0ef
commit 4182513d63
2 changed files with 8 additions and 5 deletions

View file

@ -69,13 +69,16 @@ void PGNGameBase::Reset() {
std::shared_ptr<Game> PGNGameBase::GetGame(std::uint32_t id) {
Reset();
std::uint32_t curid = 0;
while (NextGame()) {
if (id == curid) {
return (GetCurrentGame());
while(curid!= id){
try {
pgn->GotoNextGame(); // Faster than pgn->ParseNextGame()
} catch (...) {
return nullptr;
}
curid++;
}
return nullptr;
pgn->ParseNextGame();
return GetCurrentGame();
}
void PGNGameBase::Save(std::vector<std::uint32_t> to_delete,