forked from VimPlug/jedi
move parser cache to cache.py - centralize all caches there
This commit is contained in:
@@ -8,10 +8,16 @@ time_caches = []
|
|||||||
|
|
||||||
star_import_cache = {}
|
star_import_cache = {}
|
||||||
|
|
||||||
|
# for fast_parser, should never be deleted
|
||||||
|
parser_cache = {}
|
||||||
|
|
||||||
|
|
||||||
def clear_caches(delete_all=False):
|
def clear_caches(delete_all=False):
|
||||||
""" Jedi caches many things, that should be completed after each completion
|
""" Jedi caches many things, that should be completed after each completion
|
||||||
finishes.
|
finishes.
|
||||||
|
|
||||||
|
:param delete_all: Deletes also the cache that is normally not deleted,
|
||||||
|
like parser cache, which is important for faster parsing.
|
||||||
"""
|
"""
|
||||||
global memoize_caches
|
global memoize_caches
|
||||||
|
|
||||||
@@ -31,6 +37,7 @@ def clear_caches(delete_all=False):
|
|||||||
global time_caches
|
global time_caches
|
||||||
time_caches = []
|
time_caches = []
|
||||||
star_import_cache.clear()
|
star_import_cache.clear()
|
||||||
|
parser_cache.clear()
|
||||||
|
|
||||||
|
|
||||||
def memoize_default(default=None, cache=memoize_caches):
|
def memoize_default(default=None, cache=memoize_caches):
|
||||||
|
|||||||
@@ -4,8 +4,7 @@ import operator
|
|||||||
from _compatibility import use_metaclass, reduce, property
|
from _compatibility import use_metaclass, reduce, property
|
||||||
import settings
|
import settings
|
||||||
import parsing
|
import parsing
|
||||||
|
import cache
|
||||||
parser_cache = {}
|
|
||||||
|
|
||||||
|
|
||||||
class Module(parsing.Simple, parsing.Module):
|
class Module(parsing.Simple, parsing.Module):
|
||||||
@@ -140,12 +139,12 @@ class CachedFastParser(type):
|
|||||||
def __call__(self, code, module_path=None, user_position=None):
|
def __call__(self, code, module_path=None, user_position=None):
|
||||||
if not settings.fast_parser:
|
if not settings.fast_parser:
|
||||||
return parsing.PyFuzzyParser(code, module_path, user_position)
|
return parsing.PyFuzzyParser(code, module_path, user_position)
|
||||||
if module_path is None or module_path not in parser_cache:
|
if module_path is None or module_path not in cache.parser_cache:
|
||||||
p = super(CachedFastParser, self).__call__(code, module_path,
|
p = super(CachedFastParser, self).__call__(code, module_path,
|
||||||
user_position)
|
user_position)
|
||||||
parser_cache[module_path] = p
|
cache.parser_cache[module_path] = p
|
||||||
else:
|
else:
|
||||||
p = parser_cache[module_path]
|
p = cache.parser_cache[module_path]
|
||||||
p.update(code, user_position)
|
p.update(code, user_position)
|
||||||
return p
|
return p
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user