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 | 6e98cdebf4f2491b5d366d72ccb9b98d1373ff22 (patch) | |
| tree | 5403ad3a0803452c90799aeb3ca898c8070966a0 | |
| parent | 1233d558dc602ef9e367ee1ccd701ff8faed4bd9 (diff) | |
| download | bcm5719-llvm-6e98cdebf4f2491b5d366d72ccb9b98d1373ff22.tar.gz bcm5719-llvm-6e98cdebf4f2491b5d366d72ccb9b98d1373ff22.zip | |
[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.
llvm-svn: 162200
| -rw-r--r-- | clang/bindings/python/clang/cindex.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py index 0605c2416fd..628ade15932 100644 --- a/clang/bindings/python/clang/cindex.py +++ b/clang/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) |

