Merge pull request #3815 from blongden/cmdset_merge_improvements
Improve performance on larger cmdsets
This commit is contained in:
commit
e9a69ee3df
2 changed files with 3 additions and 3 deletions
|
|
@ -32,7 +32,6 @@ from collections import defaultdict
|
||||||
from copy import copy
|
from copy import copy
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
from traceback import format_exc
|
from traceback import format_exc
|
||||||
from weakref import WeakValueDictionary
|
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
|
|
@ -49,7 +48,7 @@ _IN_GAME_ERRORS = settings.IN_GAME_ERRORS
|
||||||
|
|
||||||
__all__ = ("cmdhandler", "InterruptCommand")
|
__all__ = ("cmdhandler", "InterruptCommand")
|
||||||
_GA = object.__getattribute__
|
_GA = object.__getattribute__
|
||||||
_CMDSET_MERGE_CACHE = WeakValueDictionary()
|
_CMDSET_MERGE_CACHE = {}
|
||||||
|
|
||||||
# tracks recursive calls by each caller
|
# tracks recursive calls by each caller
|
||||||
# to avoid infinite loops (commands calling themselves)
|
# to avoid infinite loops (commands calling themselves)
|
||||||
|
|
|
||||||
|
|
@ -248,7 +248,8 @@ class CmdSet(object, metaclass=_CmdSetMeta):
|
||||||
if cmdset_a.duplicates and cmdset_a.priority == cmdset_b.priority:
|
if cmdset_a.duplicates and cmdset_a.priority == cmdset_b.priority:
|
||||||
cmdset_c.commands.extend(cmdset_b.commands)
|
cmdset_c.commands.extend(cmdset_b.commands)
|
||||||
else:
|
else:
|
||||||
cmdset_c.commands.extend([cmd for cmd in cmdset_b if cmd not in cmdset_a])
|
existing_commands = set(cmdset_a.commands)
|
||||||
|
cmdset_c.commands.extend([cmd for cmd in cmdset_b if cmd not in existing_commands])
|
||||||
return cmdset_c
|
return cmdset_c
|
||||||
|
|
||||||
def _intersect(self, cmdset_a, cmdset_b):
|
def _intersect(self, cmdset_a, cmdset_b):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue