Skip to content

Commit 3cc45f8

Browse files
minadtarsius
authored andcommitted
Optimize mode filtering
Extract a separate function to allow compilation instead of slow evaluation. This optimization helps when scrolling through large documents, where previously the minions mode line eval appeared in the profile for redisplay. The bottleneck is `pcase-lambda', which performs horribly when not compiled. Because the whole file might not be compiled drop using it altogether. Also use `cl-filter-if-not' instead of `seq-filter', for an additional, though tiny speedup, and also because it allows dropping a dependency.
1 parent 1be68e8 commit 3cc45f8

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

minions.el

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
;;; Code:
4242

4343
(require 'cl-lib)
44-
(require 'seq)
4544

4645
(eval-when-compile
4746
(require 'subr-x))
@@ -154,9 +153,7 @@ mouse-3: Toggle minor modes"
154153
'mouse-face 'mode-line-highlight
155154
'local-map (make-mode-line-mouse-map
156155
'mouse-2 #'mode-line-widen))
157-
`(:propertize ("" (:eval (seq-filter (pcase-lambda (`(,mode))
158-
(memq mode minions-direct))
159-
minor-mode-alist)))
156+
`(:propertize ("" (:eval (minions--modes-direct)))
160157
mouse-face mode-line-highlight
161158
help-echo "Minor mode
162159
mouse-1: Display minor mode menu
@@ -215,6 +212,11 @@ Otherwise the entry can only be used to toggle the mode."
215212
(popup-menu map)
216213
(quit nil))))
217214

215+
(defun minions--modes-direct ()
216+
(cl-remove-if-not (lambda (mode)
217+
(memq (car mode) minions-direct))
218+
minor-mode-alist))
219+
218220
(defun minions--modes ()
219221
(let (local global)
220222
(dolist (mode (cl-set-difference

0 commit comments

Comments
 (0)