From: Leo Liu Date: Sat, 10 Nov 2012 01:28:22 +0000 (+0800) Subject: * lisp/ido.el (ido-set-matches-1): Improve flex matching performance by X-Git-Tag: emacs-24.3.90~173^2~18^2~141 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=05a859c1bd9cd07b2c0fad06a0694e88ea929fcf;p=emacs.git * lisp/ido.el (ido-set-matches-1): Improve flex matching performance by removing backtracking in the regexp (suggested by Stefan). Fixes: debbugs:12796 --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a07749e4f18..fb436fa0038 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2012-11-10 Leo Liu + + * ido.el (ido-set-matches-1): Improve flex matching performance by + removing backtracking in the regexp (suggested by Stefan). (Bug#12796) + 2012-11-09 Stefan Monnier * emacs-lisp/advice.el (ad-set-advice-info): Set defalias-fset-function. diff --git a/lisp/ido.el b/lisp/ido.el index 4ab183b3207..f4f9c27c847 100644 --- a/lisp/ido.el +++ b/lisp/ido.el @@ -3764,7 +3764,11 @@ This is to make them appear as if they were \"virtual buffers\"." ido-enable-flex-matching (> (length ido-text) 1) (not ido-enable-regexp)) - (setq re (mapconcat #'regexp-quote (split-string ido-text "") ".*")) + (setq re (concat (regexp-quote (string (aref ido-text 0))) + (mapconcat (lambda (c) + (concat "[^" (string c) "]*" + (regexp-quote (string c)))) + (substring ido-text 1) ""))) (if ido-enable-prefix (setq re (concat "\\`" re))) (mapc