summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnold Noronha <arnold@tdrhq.com>2020-05-29 02:35:58 +0300
committerDmitry Gutov <dgutov@yandex.ru>2020-05-29 02:35:58 +0300
commitdf4991093b94ccc48255a0387a98c536962fd0a7 (patch)
tree1282e3f1bcf484aea8626ac3d3135b2121671ba1
parent7865820f6b04486f4408fce30c2266379b0d59e8 (diff)
downloademacs-df4991093b94ccc48255a0387a98c536962fd0a7.tar.gz
Create a buffer-local binding to improve performance
* lisp/ido.el (ido-make-buffer-list-1): Create a buffer-local binding to improve performance when a lot of buffers are open (bug#41029). Copyright-paperwork-exempt: yes
-rw-r--r--lisp/ido.el19
1 files changed, 12 insertions, 7 deletions
diff --git a/lisp/ido.el b/lisp/ido.el
index 4fb01c68dfa..e834916a6da 100644
--- a/lisp/ido.el
+++ b/lisp/ido.el
@@ -3410,13 +3410,18 @@ instead removed from the current item list."
(defun ido-make-buffer-list-1 (&optional frame visible)
"Return list of non-ignored buffer names."
- (delq nil
- (mapcar
- (lambda (x)
- (let ((name (buffer-name x)))
- (if (not (or (ido-ignore-item-p name ido-ignore-buffers) (member name visible)))
- name)))
- (buffer-list frame))))
+ (with-temp-buffer
+ ;; Each call to ido-ignore-item-p LET-binds case-fold-search.
+ ;; That is slow if there's no buffer-local binding available,
+ ;; roughly O(number of buffers). This hack avoids it.
+ (setq-local case-fold-search nil)
+ (delq nil
+ (mapcar
+ (lambda (x)
+ (let ((name (buffer-name x)))
+ (if (not (or (ido-ignore-item-p name ido-ignore-buffers) (member name visible)))
+ name)))
+ (buffer-list frame)))))
(defun ido-make-buffer-list (default)
"Return the current list of buffers.