diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2023-01-20 10:08:10 +0100 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2023-01-20 10:08:10 +0100 |
| commit | 4182513d63f67e1b0f9da7b93f7a48d959e3133f (patch) | |
| tree | 6f3f56ec98e154eeaaf59953b984f45a24bbbb33 | |
| parent | 1eca34d0ef74ba17178728f0e75bd2504af463ee (diff) | |
Integrate GotoNextGame() for better efficiency
| -rw-r--r-- | TODO.md | 2 | ||||
| -rw-r--r-- | src/base_tab/gamebase/PGNGameBase.cpp | 11 |
2 files changed, 8 insertions, 5 deletions
@@ -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<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, |
