diff options
-rw-r--r-- | bindings/python/clang/cindex.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py index 474e10b434..5e261f8657 100644 --- a/bindings/python/clang/cindex.py +++ b/bindings/python/clang/cindex.py @@ -1659,6 +1659,7 @@ class CompletionChunk: def __init__(self, completionString, key): self.cs = completionString self.key = key + self.__kindNumberCache = -1 def __repr__(self): return "{'" + self.spelling + "', " + str(self.kind) + "}" @@ -1667,10 +1668,15 @@ class CompletionChunk: def spelling(self): return conf.lib.clang_getCompletionChunkText(self.cs, self.key).spelling - @CachedProperty + # We do not use @CachedProperty here, as the manual implementation is + # apparently still significantly faster. Please profile carefully if you + # would like to add CachedProperty back. + @property def __kindNumber(self): - res = conf.lib.clang_getCompletionChunkKind(self.cs, self.key) - return res + if self.__kindNumberCache == -1: + self.__kindNumberCache = \ + conf.lib.clang_getCompletionChunkKind(self.cs, self.key) + return self.__kindNumberCache @CachedProperty def kind(self): |