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
|
;;;###autoload
|
||||||
(defun doom-system-distro ()
|
(defun doom-system-distro ()
|
||||||
"Return a symbol representing the installed distro."
|
"Return a symbol representing the installed distro."
|
||||||
(cond (IS-WINDOWS 'windows)
|
;; REVIEW Use `with-memoization' when 27.x support is dropped
|
||||||
(IS-MAC 'macos)
|
(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")
|
((and (file-exists-p "/etc/os-release")
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
(insert-file-contents "/etc/os-release")
|
(insert-file-contents "/etc/os-release")
|
||||||
|
@ -19,7 +22,7 @@
|
||||||
(file-directory-p "/run/current-system"))
|
(file-directory-p "/run/current-system"))
|
||||||
(executable-find "guix"))
|
(executable-find "guix"))
|
||||||
'guix)
|
'guix)
|
||||||
('linux)))
|
('linux)))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom-system-distro-version ()
|
(defun doom-system-distro-version ()
|
||||||
|
@ -49,6 +52,9 @@
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom-system-distro-icon ()
|
(defun doom-system-distro-icon ()
|
||||||
"Display icon for the installed distro."
|
"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
|
(propertize
|
||||||
(pcase (doom-system-distro)
|
(pcase (doom-system-distro)
|
||||||
(`windows (all-the-icons-faicon "windows"))
|
(`windows (all-the-icons-faicon "windows"))
|
||||||
|
@ -75,7 +81,7 @@
|
||||||
((or `void `artix) "\uF17c")
|
((or `void `artix) "\uF17c")
|
||||||
(_ (all-the-icons-faicon "linux")))
|
(_ (all-the-icons-faicon "linux")))
|
||||||
'face '(:height 1)
|
'face '(:height 1)
|
||||||
'display '(raise 0)))
|
'display '(raise 0)))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom-system-cpus ()
|
(defun doom-system-cpus ()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue