forked from VimPlug/jedi
Fix the fundamentally wrong cache.
This commit is contained in:
@@ -80,13 +80,13 @@ def time_cache(time_add_setting):
|
|||||||
def memoize_method(method):
|
def memoize_method(method):
|
||||||
"""A normal memoize function."""
|
"""A normal memoize function."""
|
||||||
def wrapper(self, *args, **kwargs):
|
def wrapper(self, *args, **kwargs):
|
||||||
dct = self.__dict__.setdefault('_memoize_method_dct', {})
|
cache_dict = self.__dict__.setdefault('_memoize_method_dct', {})
|
||||||
|
dct = cache_dict.setdefault(method, {})
|
||||||
key = (args, frozenset(kwargs.items()))
|
key = (args, frozenset(kwargs.items()))
|
||||||
try:
|
try:
|
||||||
return dct[key]
|
return dct[key]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
result = method(self, *args, **kwargs)
|
result = method(self, *args, **kwargs)
|
||||||
# TODO THIS IS FUNDAMENTALLY WRONG, METHOD SHOULD BE INCLUDED.
|
|
||||||
dct[key] = result
|
dct[key] = result
|
||||||
return result
|
return result
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|||||||
Reference in New Issue
Block a user