Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Optimized the autocomplete search so that it uses a binary search ins…

…tead of a linear search.
  • Loading branch information...
commit 04c45a7eebccdd85003beaf1e966b392a6d432f2 1 parent fc24ed5
@whatthejeff whatthejeff authored
Showing with 7 additions and 4 deletions.
  1. +7 −4 src/__init__.py
View
11 src/__init__.py
@@ -4,6 +4,7 @@
from subprocess import Popen, PIPE
from threading import Thread
+from bisect import bisect
import ansicolor as clr
import cmd_util as cu
import ctags
@@ -500,9 +501,11 @@ def tab_complete(text, state):
return None
if state == 0:
self.autocomplete_cache = []
- for identifier in self.autocomplete_identifiers:
- if identifier.startswith(text):
- self.autocomplete_cache.append(identifier)
+ pos = bisect(self.autocomplete_identifiers, text)
+
+ while self.autocomplete_identifiers[pos].startswith(text):
+ self.autocomplete_cache.append(self.autocomplete_identifiers[pos])
+ pos = pos + 1
if self.function_signatures.has_key(text):
for sig in self.function_signatures[text]:
@@ -723,7 +726,7 @@ def php_open(self):
p_line = self.p.stdout.readline().rstrip()
if p_line == "#end_autocomplete_identifiers":
break
- self.autocomplete_identifiers.append(p_line)
+ self.autocomplete_identifiers.insert(bisect(self.autocomplete_identifiers, p_line), p_line)
def wait_for_comm_finish(self, defer_output=False):
try:
Please sign in to comment.
Something went wrong with that request. Please try again.