1
0
forked from VimPlug/jedi

simplify parser_cache checks

This commit is contained in:
David Halter
2013-01-10 12:10:35 +01:00
parent 9031e425be
commit 7c02632fdc

View File

@@ -139,12 +139,13 @@ class CachedFastParser(type):
def __call__(self, source, module_path=None, user_position=None):
if not settings.fast_parser:
return parsing.PyFuzzyParser(source, module_path, user_position)
if module_path is None or module_path not in cache.parser_cache:
p = cache.parser_cache.get(module_path, None)
if p is None or isinstance(p, parsing.PyFuzzyParser):
p = super(CachedFastParser, self).__call__(source, module_path,
user_position)
cache.parser_cache[module_path] = p
else:
p = cache.parser_cache[module_path]
p.update(source, user_position)
return p