]> git.eshelyaron.com Git - emacs.git/commitdiff
Create a buffer-local binding to improve performance
authorArnold Noronha <arnold@tdrhq.com>
Thu, 28 May 2020 23:35:58 +0000 (02:35 +0300)
committerDmitry Gutov <dgutov@yandex.ru>
Thu, 28 May 2020 23:35:58 +0000 (02:35 +0300)
* 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

lisp/ido.el

index 4fb01c68dfaf89473c2cd9ac267e0aa11948c472..e834916a6dadd0963da4b42f6f97970bae3e0282 100644 (file)
@@ -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.