Refactor startup optimizations

+ Add doom-gc-cons-upper-limit variable
+ Don't use most-positive-fixnum, in case Emacs somehow wants to
  allocate that much!
+ Don't use startup optimizations in noninteractive sessions
+ Restore gc-cons-threshold on idle timer, instead of hook (to defer the
  possible GC pause and so deferred packages can take advantage of these
  optimizations).
This commit is contained in:
Henrik Lissner 2018-09-03 01:18:52 +02:00
parent 81ee563c4c
commit eaa10946f1
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 33 additions and 23 deletions

View file

@ -300,7 +300,7 @@ original value of `symbol-file'."
;; Don't garbage collect to speed up minibuffer commands
(defun doom|defer-garbage-collection ()
(setq gc-cons-threshold most-positive-fixnum))
(setq gc-cons-threshold doom-gc-cons-upper-limit))
(defun doom|restore-garbage-collection ()
(setq gc-cons-threshold doom-gc-cons-threshold))
(add-hook 'minibuffer-setup-hook #'doom|defer-garbage-collection)
@ -318,12 +318,13 @@ easier to tell where the came from.
Meant to be used with `run-hook-wrapped'."
(when doom-debug-mode
(message "Running doom hook: %s" hook))
(condition-case e
(funcall hook)
((debug error)
(signal 'doom-hook-error (list hook e))))
;; return nil so `run-hook-wrapped' won't short circuit
nil)
(let ((gc-cons-threshold doom-gc-cons-upper-limit))
(condition-case e
(funcall hook)
((debug error)
(signal 'doom-hook-error (list hook e))))
;; return nil so `run-hook-wrapped' won't short circuit
nil))
(defun doom-ensure-same-emacs-version-p ()
"Check if the running version of Emacs has changed and set