mirror of
https://github.com/evennia/evennia.git
synced 2025-10-29 19:35:56 +00:00
Merge pull request #3815 from blongden/cmdset_merge_improvements
Improve performance on larger cmdsets
This commit is contained in:
commit
e9a69ee3df
@ -32,7 +32,6 @@ from collections import defaultdict
|
||||
from copy import copy
|
||||
from itertools import chain
|
||||
from traceback import format_exc
|
||||
from weakref import WeakValueDictionary
|
||||
|
||||
from django.conf import settings
|
||||
from django.utils.translation import gettext as _
|
||||
@ -49,7 +48,7 @@ _IN_GAME_ERRORS = settings.IN_GAME_ERRORS
|
||||
|
||||
__all__ = ("cmdhandler", "InterruptCommand")
|
||||
_GA = object.__getattribute__
|
||||
_CMDSET_MERGE_CACHE = WeakValueDictionary()
|
||||
_CMDSET_MERGE_CACHE = {}
|
||||
|
||||
# tracks recursive calls by each caller
|
||||
# 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:
|
||||
cmdset_c.commands.extend(cmdset_b.commands)
|
||||
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
|
||||
|
||||
def _intersect(self, cmdset_a, cmdset_b):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user