Browse files

Merge branch 'autocomplete_optimizations' of http://github.com/whatth…

…ejeff/phpsh into stufffromgithub
  • Loading branch information...
2 parents 199591e + 04c45a7 commit 1f8ad4873c8a72dc9754affef410b59e50f8c324 adonohue committed Sep 15, 2010
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]:
@@ -707,7 +710,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:

0 comments on commit 1f8ad48

Please sign in to comment.