Merge pull request #2720 from InspectorCaracal/sdesc_key_parse
`rpsystem` contrib: cache regex tuples by ID instead of key+aliases
This commit is contained in:
commit
b3b87a5a1c
1 changed files with 4 additions and 3 deletions
|
|
@ -319,14 +319,15 @@ def regex_tuple_from_key_alias(obj):
|
|||
"""
|
||||
global _REGEX_TUPLE_CACHE
|
||||
permutation_string = " ".join([obj.key] + obj.aliases.all())
|
||||
cache_key = f"{obj.id} {permutation_string}"
|
||||
|
||||
if permutation_string not in _REGEX_TUPLE_CACHE:
|
||||
_REGEX_TUPLE_CACHE[permutation_string] = (
|
||||
if cache_key not in _REGEX_TUPLE_CACHE:
|
||||
_REGEX_TUPLE_CACHE[cache_key] = (
|
||||
re.compile(ordered_permutation_regex(permutation_string), _RE_FLAGS),
|
||||
obj,
|
||||
obj.key,
|
||||
)
|
||||
return _REGEX_TUPLE_CACHE[permutation_string]
|
||||
return _REGEX_TUPLE_CACHE[cache_key]
|
||||
|
||||
|
||||
def parse_language(speaker, emote):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue