[cfe-commits] r172899 - /cfe/trunk/bindings/python/clang/cindex.py

Tobias Grosser grosser at fim.uni-passau.de
Sat Jan 19 03:03:40 PST 2013


Author: grosser
Date: Sat Jan 19 05:03:40 2013
New Revision: 172899

URL: http://llvm.org/viewvc/llvm-project?rev=172899&view=rev
Log:
[cindex.py]: Speed up lookup of the completion kind

We can directly the number of the kind instead of going through the
completionChunkKindMap.

Formatting time changes from 0.84 to 0.72 seconds.

Modified:
    cfe/trunk/bindings/python/clang/cindex.py

Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=172899&r1=172898&r2=172899&view=diff
==============================================================================
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Sat Jan 19 05:03:40 2013
@@ -1668,9 +1668,13 @@
         return conf.lib.clang_getCompletionChunkText(self.cs, self.key).spelling
 
     @CachedProperty
-    def kind(self):
+    def __kindNumber(self):
         res = conf.lib.clang_getCompletionChunkKind(self.cs, self.key)
-        return completionChunkKindMap[res]
+	return res
+
+    @CachedProperty
+    def kind(self):
+        return completionChunkKindMap[self.__kindNumber]
 
     @CachedProperty
     def string(self):
@@ -1683,19 +1687,19 @@
           None
 
     def isKindOptional(self):
-      return self.kind == completionChunkKindMap[0]
+      return self.__kindNumber == 0
 
     def isKindTypedText(self):
-      return self.kind == completionChunkKindMap[1]
+      return self.__kindNumber == 1
 
     def isKindPlaceHolder(self):
-      return self.kind == completionChunkKindMap[3]
+      return self.__kindNumber == 3
 
     def isKindInformative(self):
-      return self.kind == completionChunkKindMap[4]
+      return self.__kindNumber == 4
 
     def isKindResultType(self):
-      return self.kind == completionChunkKindMap[15]
+      return self.__kindNumber == 15
 
 completionChunkKindMap = {
             0: CompletionChunk.Kind("Optional"),





More information about the cfe-commits mailing list