cache regex tuples by id

This commit is contained in:
InspectorCaracal 2022-04-07 13:17:22 -06:00 committed by GitHub
parent 8f1f604708
commit cd611199b1

View file

@ -318,15 +318,15 @@ def regex_tuple_from_key_alias(obj):
"""
global _REGEX_TUPLE_CACHE
permutation_string = " ".join([obj.key] + obj.aliases.all())
if permutation_string not in _REGEX_TUPLE_CACHE:
if obj.id not in _REGEX_TUPLE_CACHE:
permutation_string = " ".join([obj.key] + obj.aliases.all())
_REGEX_TUPLE_CACHE[permutation_string] = (
re.compile(ordered_permutation_regex(permutation_string), _RE_FLAGS),
obj,
obj.key,
)
return _REGEX_TUPLE_CACHE[permutation_string]
return _REGEX_TUPLE_CACHE[obj.id]
def parse_language(speaker, emote):