reduce number of map lookups

This commit is contained in:
Maximilian Keßler 2024-02-10 00:27:00 +01:00
parent 3dafee21dd
commit 9af42a43a4
Signed by: max
GPG Key ID: BCC5A619923C0BA5

View File

@ -1034,8 +1034,10 @@ namespace Hanabi
return 0; return 0;
} }
#ifndef GAME_STATE_NO_TABLEBASE_LOOKUP #ifndef GAME_STATE_NO_TABLEBASE_LOOKUP
if (_position_tablebase.count(id_of_state) == 1) { auto lookup_it = _position_tablebase.find(id_of_state);
return _position_tablebase[id_of_state]; if (lookup_it != _position_tablebase.end())
{
return lookup_it->second;
} }
#endif #endif
@ -1401,10 +1403,12 @@ namespace Hanabi
std::cout << "\n" << std::endl; std::cout << "\n" << std::endl;
} }
#endif #endif
#ifndef NDEBUG
if (_position_tablebase.count(id) == 1) if (_position_tablebase.count(id) == 1)
{ {
ASSERT(_position_tablebase[id] == probability); ASSERT(_position_tablebase[id] == probability);
} }
#endif
if (save_state_to_map()) if (save_state_to_map())
{ {
_position_tablebase[id] = probability; _position_tablebase[id] = probability;