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

@ -7,7 +7,7 @@
- [x] Bind the chess game editor settings to EditorPrefs.hpp - [x] Bind the chess game editor settings to EditorPrefs.hpp
- [x] Ask before closing MainWindow/Tabs if anything is not saved - [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) - [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] Clean and debug DragNDrop in BoardCanvas
- [x] Disable the "Analyze entire game" button (Not Yet Implemented) - [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 - [x] Keep engine evaluation bar visible (and best move arrows) as long as the live engine dialog is open

View file

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