mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-17 13:43:51 +01:00
Pull out if statement from for loop
This commit is contained in:
parent
e3417a06e2
commit
bd7bb5df71
1 changed files with 14 additions and 6 deletions
|
@ -471,14 +471,22 @@ class CacheListDescriptor(_CacheDescriptorBase):
|
||||||
results = {}
|
results = {}
|
||||||
cached_defers = {}
|
cached_defers = {}
|
||||||
missing = []
|
missing = []
|
||||||
|
|
||||||
|
# If the cache takes a single arg then that is used as the key,
|
||||||
|
# otherwise a tuple is used.
|
||||||
|
if num_args == 1:
|
||||||
|
def cache_get(arg):
|
||||||
|
return cache.get(arg, callback=invalidate_callback)
|
||||||
|
else:
|
||||||
|
key = list(keyargs)
|
||||||
|
|
||||||
|
def cache_get(arg):
|
||||||
|
key[self.list_pos] = arg
|
||||||
|
return cache.get(tuple(key), callback=invalidate_callback)
|
||||||
|
|
||||||
for arg in list_args:
|
for arg in list_args:
|
||||||
try:
|
try:
|
||||||
if num_args == 1:
|
res = cache_get(arg)
|
||||||
res = cache.get(arg, callback=invalidate_callback)
|
|
||||||
else:
|
|
||||||
key = list(keyargs)
|
|
||||||
key[self.list_pos] = arg
|
|
||||||
res = cache.get(tuple(key), callback=invalidate_callback)
|
|
||||||
|
|
||||||
if not isinstance(res, ObservableDeferred):
|
if not isinstance(res, ObservableDeferred):
|
||||||
results[arg] = res
|
results[arg] = res
|
||||||
|
|
Loading…
Reference in a new issue