diff options
author | Tobias Grosser <grosser@fim.uni-passau.de> | 2012-08-20 10:38:16 +0000 |
---|---|---|
committer | Tobias Grosser <grosser@fim.uni-passau.de> | 2012-08-20 10:38:16 +0000 |
commit | 147785b852ed247ebfd568a92579f7bc1fe347c8 (patch) | |
tree | 532a6d1fef38d85cba5e61767a96cf8f46cba0c7 /bindings/python | |
parent | 5965b7c7ddf8d9635426943a05441c71cb59fef6 (diff) |
[cindex.py] Cache the number of chunks in CompletionString
Without this patch, lib.clang_getNumCompletionChunks is called at
each _iteration_ of a 'for chunk in CompletionString' loop. Now we
call it just once.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162200 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'bindings/python')
-rw-r--r-- | bindings/python/clang/cindex.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py index 0605c2416f..628ade1593 100644 --- a/bindings/python/clang/cindex.py +++ b/bindings/python/clang/cindex.py @@ -1725,10 +1725,14 @@ class CompletionString(ClangObject): return "<Availability: %s>" % self def __len__(self): + self.num_chunks + + @CachedProperty + def num_chunks(self): return lib.clang_getNumCompletionChunks(self.obj) def __getitem__(self, key): - if len(self) <= key: + if self.num_chunks <= key: raise IndexError return CompletionChunk(self.obj, key) |