mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-27 14:23:43 -05:00
Move GC optimization to init.el
And reformat core.el
This commit is contained in:
16
init.el
16
init.el
@@ -45,7 +45,21 @@ decrease this. If you experience stuttering, increase this.")
|
||||
;; Do this on idle timer to defer a possible GC pause that could result; also
|
||||
;; allows deferred packages to take advantage of these optimizations.
|
||||
(run-with-idle-timer
|
||||
3 nil (lambda () (setq-default gc-cons-threshold doom-gc-cons-threshold))))
|
||||
3 nil
|
||||
(lambda ()
|
||||
(setq-default gc-cons-threshold doom-gc-cons-threshold)
|
||||
;; To speed up minibuffer commands (like helm and ivy), we defer garbage
|
||||
;; collection while the minibuffer is active.
|
||||
(defun doom|defer-garbage-collection ()
|
||||
(setq gc-cons-threshold doom-gc-cons-upper-limit))
|
||||
(defun doom|restore-garbage-collection ()
|
||||
;; Defer it so that commands launched from the minibuffer can enjoy the
|
||||
;; benefits.
|
||||
(run-at-time 1 nil (lambda () (setq gc-cons-threshold doom-gc-cons-threshold))))
|
||||
(add-hook 'minibuffer-setup-hook #'doom|defer-garbage-collection)
|
||||
(add-hook 'minibuffer-exit-hook #'doom|restore-garbage-collection)
|
||||
;; GC all sneaky breeky like
|
||||
(add-hook 'focus-out-hook #'garbage-collect))))
|
||||
|
||||
|
||||
(if (ignore-errors (or after-init-time noninteractive))
|
||||
|
Reference in New Issue
Block a user