emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master d96dd127e39 3/4: Speed up dictionary--count-mode-buffers


From: Stefan Kangas
Subject: master d96dd127e39 3/4: Speed up dictionary--count-mode-buffers
Date: Wed, 16 Aug 2023 15:45:49 -0400 (EDT)

branch: master
commit d96dd127e392d05c2753908661d27760cedd5d2d
Author: Stefan Kangas <stefankangas@gmail.com>
Commit: Stefan Kangas <stefankangas@gmail.com>

    Speed up dictionary--count-mode-buffers
    
    * lisp/net/dictionary.el (dictionary--count-mode-buffers): Make
    faster.  Patch by Visuwesh <visuweshm@gmail.com>.
---
 lisp/net/dictionary.el | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/lisp/net/dictionary.el b/lisp/net/dictionary.el
index f4a381db75d..58f36db2523 100644
--- a/lisp/net/dictionary.el
+++ b/lisp/net/dictionary.el
@@ -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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]