Pull out if statement from for loop
This commit is contained in:
parent
e3417a06e2
commit
bd7bb5df71
|
@ -471,14 +471,22 @@ class CacheListDescriptor(_CacheDescriptorBase):
|
||||||
results = {}
|
results = {}
|
||||||
cached_defers = {}
|
cached_defers = {}
|
||||||
missing = []
|
missing = []
|
||||||
for arg in list_args:
|
|
||||||
try:
|
# If the cache takes a single arg then that is used as the key,
|
||||||
|
# otherwise a tuple is used.
|
||||||
if num_args == 1:
|
if num_args == 1:
|
||||||
res = cache.get(arg, callback=invalidate_callback)
|
def cache_get(arg):
|
||||||
|
return cache.get(arg, callback=invalidate_callback)
|
||||||
else:
|
else:
|
||||||
key = list(keyargs)
|
key = list(keyargs)
|
||||||
|
|
||||||
|
def cache_get(arg):
|
||||||
key[self.list_pos] = arg
|
key[self.list_pos] = arg
|
||||||
res = cache.get(tuple(key), callback=invalidate_callback)
|
return cache.get(tuple(key), callback=invalidate_callback)
|
||||||
|
|
||||||
|
for arg in list_args:
|
||||||
|
try:
|
||||||
|
res = cache_get(arg)
|
||||||
|
|
||||||
if not isinstance(res, ObservableDeferred):
|
if not isinstance(res, ObservableDeferred):
|
||||||
results[arg] = res
|
results[arg] = res
|
||||||
|
|
Loading…
Reference in New Issue