diff --git a/TODO.md b/TODO.md index 266c50d..8dfd236 100644 --- a/TODO.md +++ b/TODO.md @@ -7,7 +7,7 @@ - [x] Bind the chess game editor settings to EditorPrefs.hpp - [x] Ask before closing MainWindow/Tabs if anything is not saved - [x] Disable the save button in GameTab after saving (and re-enable it on new changes) - - [ ] Make PGNGameBase use GotoNextGame() instead of ParseNextGame() in the NextGame() method to improve performance + - [x] Make PGNGameBase use GotoNextGame() instead of ParseNextGame() in the NextGame() method to improve performance - [x] Clean and debug DragNDrop in BoardCanvas - [x] Disable the "Analyze entire game" button (Not Yet Implemented) - [x] Keep engine evaluation bar visible (and best move arrows) as long as the live engine dialog is open diff --git a/src/base_tab/gamebase/PGNGameBase.cpp b/src/base_tab/gamebase/PGNGameBase.cpp index a969451..01da01f 100644 --- a/src/base_tab/gamebase/PGNGameBase.cpp +++ b/src/base_tab/gamebase/PGNGameBase.cpp @@ -69,13 +69,16 @@ void PGNGameBase::Reset() { std::shared_ptr 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 to_delete,