]> git.eshelyaron.com Git - emacs.git/commitdiff
Speed up dictionary--count-mode-buffers
authorStefan Kangas <stefankangas@gmail.com>
Wed, 16 Aug 2023 19:25:49 +0000 (21:25 +0200)
committerStefan Kangas <stefankangas@gmail.com>
Wed, 16 Aug 2023 19:27:50 +0000 (21:27 +0200)
* lisp/net/dictionary.el (dictionary--count-mode-buffers): Make
faster.  Patch by Visuwesh <visuweshm@gmail.com>.

lisp/net/dictionary.el

index f4a381db75d295699737459cdc1df16ac1466045..58f36db252369d4345548a470a6e0d77fda5157e 100644 (file)
@@ -574,13 +574,13 @@ The connection takes the proxy setting in customization group
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (defun dictionary--count-mode-buffers ()
-  "Return the number of buffers that "
-  (seq-reduce #'+
-              (mapcar
-               (lambda (buf)
-                 (with-current-buffer buf
-                   (if (derived-mode-p 'dictionary-mode) 1 0)))
-               (buffer-list))
+  (seq-reduce (lambda (count buf)
+                (if (provided-mode-derived-p
+                     (buffer-local-value 'major-mode buf)
+                     'dictionary-mode)
+                    (+ count 1)
+                  count))
+              (buffer-list)
               0))
 
 (defun dictionary-close (&rest _ignored)