perf(lib): memoize doom-system-* functions
This commit is contained in:
parent
3239ab8b2e
commit
c540f1b515
1 changed files with 50 additions and 44 deletions
|
@ -3,8 +3,11 @@
|
|||
;;;###autoload
|
||||
(defun doom-system-distro ()
|
||||
"Return a symbol representing the installed distro."
|
||||
(cond (IS-WINDOWS 'windows)
|
||||
(IS-MAC 'macos)
|
||||
;; REVIEW Use `with-memoization' when 27.x support is dropped
|
||||
(or (get 'doom-system-distro 'cached-value)
|
||||
(put 'doom-system-distro 'cached-value
|
||||
(cond ((featurep :os 'windows) 'windows)
|
||||
((featurep :os 'macos) 'macos)
|
||||
((and (file-exists-p "/etc/os-release")
|
||||
(with-temp-buffer
|
||||
(insert-file-contents "/etc/os-release")
|
||||
|
@ -19,7 +22,7 @@
|
|||
(file-directory-p "/run/current-system"))
|
||||
(executable-find "guix"))
|
||||
'guix)
|
||||
('linux)))
|
||||
('linux)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom-system-distro-version ()
|
||||
|
@ -49,6 +52,9 @@
|
|||
;;;###autoload
|
||||
(defun doom-system-distro-icon ()
|
||||
"Display icon for the installed distro."
|
||||
;; REVIEW Use `with-memoization' when 27.x support is dropped
|
||||
(or (get 'doom-system-distro-icon 'cached-value)
|
||||
(put 'doom-system-distro-icon 'cached-value
|
||||
(propertize
|
||||
(pcase (doom-system-distro)
|
||||
(`windows (all-the-icons-faicon "windows"))
|
||||
|
@ -75,7 +81,7 @@
|
|||
((or `void `artix) "\uF17c")
|
||||
(_ (all-the-icons-faicon "linux")))
|
||||
'face '(:height 1)
|
||||
'display '(raise 0)))
|
||||
'display '(raise 0)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom-system-cpus ()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue