Skip to content

Commit 5ebc252

Browse files
committed
perf(lib): use symbol plist for fn! lookup table
A good deal faster than alists at this scale.
1 parent 65c86ea commit 5ebc252

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lisp/doom-lib.el

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,15 +317,15 @@ ARGLIST."
317317
(allow-other-keys arglist))
318318
,@body)))
319319

320-
(put 'fn! 'lookup-table
321-
'((%2 . 2) (%3 . 3) (%4 . 4) (%5 . 5)
322-
(%6 . 6) (%7 . 7) (%8 . 8) (%9 . 9)))
320+
(let ((i 1))
321+
(dolist (sym '(%2 %3 %4 %5 %6 %7 %8 %9))
322+
(put 'fn! sym (cl-incf i))))
323323
(defun doom--fn-crawl (data args)
324324
(cond ((symbolp data)
325325
(when-let
326326
(pos (cond ((eq data '%*) 0)
327327
((memq data '(% %1)) 1)
328-
((cdr (assq data (get 'fn! 'lookup-table))))))
328+
((get 'fn! data))))
329329
(when (and (= pos 1)
330330
(aref args 1)
331331
(not (eq data (aref args 1))))

0 commit comments

Comments
 (0)