Skip to content
This repository

Speed up libclang, take two. #243

Merged
merged 2 commits into from about 1 year ago

2 participants

Xavier Deguillard Tobias Grosser
Xavier Deguillard
Owner

Here is some milliseconds saved. I'm however starting to be out of idea :). The only one I could see would involve rewriting formatResult and changing the snippets API.

There is actually another way: use CompleteDone autocmd, but it's too young and not mature (we cannot get the whole dict of the selected completion).

added some commits January 18, 2013
Xavier Deguillard Improve filtering: from 0.027s to 0.021s 07633dc
Xavier Deguillard Use get() to retrieve the translation unit.
While I cannot show any performance improvement, I'll argue that the
complexity of retrieving a translation unit is now two times faster.

The python "in" keyword has to walk to the datastructure once, and we
walk a second time to retrieve it. We only walk it once now.
fb8eb3d
Tobias Grosser
Collaborator

Looks fine.

Xavier Deguillard Rip-Rip merged commit fb8eb3d into from January 19, 2013
Xavier Deguillard Rip-Rip closed this January 19, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 2 unique commits by 1 author.

Jan 18, 2013
Xavier Deguillard Improve filtering: from 0.027s to 0.021s 07633dc
Xavier Deguillard Use get() to retrieve the translation unit.
While I cannot show any performance improvement, I'll argue that the
complexity of retrieving a translation unit is now two times faster.

The python "in" keyword has to walk to the datastructure once, and we
walk a second time to retrieve it. We only walk it once now.
fb8eb3d
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 3 additions and 5 deletions. Show diff stats Hide diff stats

  1. 8  plugin/libclang.py
8  plugin/libclang.py
... ...
@@ -1,7 +1,6 @@
1 1
 from clang.cindex import *
2 2
 import vim
3 3
 import time
4  
-import re
5 4
 import threading
6 5
 import os
7 6
 
@@ -144,8 +143,8 @@ def finish(self):
144 143
     print " "
145 144
 
146 145
 def getCurrentTranslationUnit(args, currentFile, fileName, update = False):
147  
-  if fileName in translationUnits:
148  
-    tu = translationUnits[fileName]
  146
+  tu = translationUnits.get(fileName)
  147
+  if tu != None:
149 148
     if update:
150 149
       if debug:
151 150
         start = time.time()
@@ -467,8 +466,7 @@ def getCurrentCompletions(base):
467 466
   timer.registerEvent("Count # Results (%s)" % str(len(results)))
468 467
 
469 468
   if base != "":
470  
-    regexp = re.compile("^" + base)
471  
-    results = filter(lambda x: regexp.match(getAbbr(x.string)), results)
  469
+    results = filter(lambda x: getAbbr(x.string).startswith(base), results)
472 470
 
473 471
   timer.registerEvent("Filter")
474 472
 
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.