perf(lib): use symbol plist for fn! lookup table
A good deal faster than alists at this scale.
This commit is contained in:
parent
65c86ea3ff
commit
5ebc2528d8
1 changed files with 4 additions and 4 deletions
|
@ -317,15 +317,15 @@ ARGLIST."
|
||||||
(allow-other-keys arglist))
|
(allow-other-keys arglist))
|
||||||
,@body)))
|
,@body)))
|
||||||
|
|
||||||
(put 'fn! 'lookup-table
|
(let ((i 1))
|
||||||
'((%2 . 2) (%3 . 3) (%4 . 4) (%5 . 5)
|
(dolist (sym '(%2 %3 %4 %5 %6 %7 %8 %9))
|
||||||
(%6 . 6) (%7 . 7) (%8 . 8) (%9 . 9)))
|
(put 'fn! sym (cl-incf i))))
|
||||||
(defun doom--fn-crawl (data args)
|
(defun doom--fn-crawl (data args)
|
||||||
(cond ((symbolp data)
|
(cond ((symbolp data)
|
||||||
(when-let
|
(when-let
|
||||||
(pos (cond ((eq data '%*) 0)
|
(pos (cond ((eq data '%*) 0)
|
||||||
((memq data '(% %1)) 1)
|
((memq data '(% %1)) 1)
|
||||||
((cdr (assq data (get 'fn! 'lookup-table))))))
|
((get 'fn! data))))
|
||||||
(when (and (= pos 1)
|
(when (and (= pos 1)
|
||||||
(aref args 1)
|
(aref args 1)
|
||||||
(not (eq data (aref args 1))))
|
(not (eq data (aref args 1))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue