diff options
author | Tobias Grosser <grosser@fim.uni-passau.de> | 2013-01-19 11:03:42 +0000 |
---|---|---|
committer | Tobias Grosser <grosser@fim.uni-passau.de> | 2013-01-19 11:03:42 +0000 |
commit | 2f1328b35b9927a5b4c58c8f041c400d17ebd42d (patch) | |
tree | abbfac2bb4bc0b089209ec7e367829c303c7af67 | |
parent | 055f4b4d00047cfd2a2fb360e8ea7874002de026 (diff) | |
download | llvm-2f1328b35b9927a5b4c58c8f041c400d17ebd42d.zip llvm-2f1328b35b9927a5b4c58c8f041c400d17ebd42d.tar.gz llvm-2f1328b35b9927a5b4c58c8f041c400d17ebd42d.tar.bz2 |
[cindex.py] Replace CachedProperty with our own implementation
This is a very performance critical point for auto completion. The manual
implementation gives a large speedup. As it does not complicate the code a lot,
I figured it is worth the change. If anybody understands why the CachedProperty
is here so much slower, I am very interested in working on an improvement of
CachedProperty.
Formatting time changes from 0.72 to 0.57 seconds.
llvm-svn: 172900
-rw-r--r-- | clang/bindings/python/clang/cindex.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py index 474e10b..5e261f8 100644 --- a/clang/bindings/python/clang/cindex.py +++ b/clang/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): |