1
0
Fork 0
mirror of https://github.com/shlomif/PySolFC.git synced 2025-04-05 00:02:29 -04:00

Refactoring / code cleanup.

Use a frozenset()-like list.

See:

* https://en.wikipedia.org/wiki/Code_refactoring

* https://www.refactoring.com/

* https://www.joelonsoftware.com/2002/01/23/rub-a-dub-dub/

Some small optimisations may have slipped in as well.
This commit is contained in:
Shlomi Fish 2020-02-07 11:44:24 +02:00
parent 8078db9abc
commit eb5e97acc7

View file

@ -471,6 +471,10 @@ class GameSaveInfo(NewStruct):
stack_caps = attr.ib(factory=list)
_Game_LOAD_CLASSES = [GameGlobalSaveInfo, GameGlobalStatsStruct, GameMoves,
GameSaveInfo, GameStatsStruct, ]
class Game(object):
# for self.gstats.updated
U_PLAY = _GLOBAL_U_PLAY
@ -3147,11 +3151,7 @@ class Game(object):
if isinstance(t, type):
if not isinstance(obj, t):
# accept old storage format in case:
if (t == GameMoves
or t == GameGlobalStatsStruct
or t == GameStatsStruct
or t == GameSaveInfo
or t == GameGlobalSaveInfo):
if t in _Game_LOAD_CLASSES:
assert isinstance(obj, Struct), err_txt
else:
assert False, err_txt