forked from OSchip/llvm-project
[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
This commit is contained in:
parent
055f4b4d00
commit
2f1328b35b
|
@ -1659,6 +1659,7 @@ class CompletionChunk:
|
||||||
def __init__(self, completionString, key):
|
def __init__(self, completionString, key):
|
||||||
self.cs = completionString
|
self.cs = completionString
|
||||||
self.key = key
|
self.key = key
|
||||||
|
self.__kindNumberCache = -1
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "{'" + self.spelling + "', " + str(self.kind) + "}"
|
return "{'" + self.spelling + "', " + str(self.kind) + "}"
|
||||||
|
@ -1667,10 +1668,15 @@ class CompletionChunk:
|
||||||
def spelling(self):
|
def spelling(self):
|
||||||
return conf.lib.clang_getCompletionChunkText(self.cs, self.key).spelling
|
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):
|
def __kindNumber(self):
|
||||||
res = conf.lib.clang_getCompletionChunkKind(self.cs, self.key)
|
if self.__kindNumberCache == -1:
|
||||||
return res
|
self.__kindNumberCache = \
|
||||||
|
conf.lib.clang_getCompletionChunkKind(self.cs, self.key)
|
||||||
|
return self.__kindNumberCache
|
||||||
|
|
||||||
@CachedProperty
|
@CachedProperty
|
||||||
def kind(self):
|
def kind(self):
|
||||||
|
|
Loading…
Reference in New Issue