Commit 7c7be184 authored by Ayush Tiwari's avatar Ayush Tiwari Committed by Romain Courteaud

sql_catalog: Simplify LazyIndexationParameterList to improve performance

__getitem__ function for LazyIndexationParameterList eats up a lot of
performance. This patch tries to simplify the code to improve
performance.
parent 1174b7f2
......@@ -255,10 +255,9 @@ class LazyIndexationParameterList(tuple):
document = self._document_list[index]
attribute = self._attribute
global_cache_key = (document.uid, attribute)
global_cache = self._global_cache
if global_cache_key in global_cache:
value = global_cache[global_cache_key]
else:
try:
value = self._global_cache[global_cache_key]
except KeyError:
value = getattr(document, attribute, None)
if callable(value):
try:
......@@ -271,7 +270,7 @@ class LazyIndexationParameterList(tuple):
error=True,
)
value = None
global_cache[global_cache_key] = value
self._global_cache[global_cache_key] = value
return value
def __iter__(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment