diff options
author | João Távora <joaotavora@gmail.com> | 2021-08-19 23:54:51 +0100 |
---|---|---|
committer | João Távora <joaotavora@gmail.com> | 2021-08-19 23:56:29 +0100 |
commit | fb81c8c3adf8633f2f617c82f6019aef630860c7 (patch) | |
tree | 8f3129e9c0d52fcd493a0db12eb356332e0e137f /lisp/icomplete.el | |
parent | a3df92f4839699388b096001b65c43f1a37273a3 (diff) | |
download | emacs-fb81c8c3adf8633f2f617c82f6019aef630860c7.tar.gz emacs-fb81c8c3adf8633f2f617c82f6019aef630860c7.tar.bz2 emacs-fb81c8c3adf8633f2f617c82f6019aef630860c7.zip |
Make icomplete-forward-completions O(1) when icomplete-scroll is t
In particular, this makes the recently added
icomplete-vertical-goto-last (bug#49005) be O(n) instead of O(n^2).
That used to be almost unbearably slow for large n.
* lisp/icomplete.el (icomplete-forward-completions): don't call last
unless needed.
Diffstat (limited to 'lisp/icomplete.el')
-rw-r--r-- | lisp/icomplete.el | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lisp/icomplete.el b/lisp/icomplete.el index 84073933894..03616f9b6aa 100644 --- a/lisp/icomplete.el +++ b/lisp/icomplete.el @@ -258,14 +258,14 @@ Return non-nil iff something was stepped." (interactive) (let* ((beg (icomplete--field-beg)) (end (icomplete--field-end)) - (comps (completion-all-sorted-completions beg end)) - (last (last comps))) + (comps (completion-all-sorted-completions beg end))) (when (consp (cdr comps)) (cond (icomplete-scroll (push (pop comps) icomplete--scrolled-past) (setq icomplete--scrolled-completions comps)) (t - (setcdr (last comps) (cons (pop comps) (cdr last))))) + (let ((last (last comps))) + (setcdr (last comps) (cons (pop comps) (cdr last)))))) (completion--cache-all-sorted-completions beg end comps)))) (defun icomplete-backward-completions () |