case-fold-search = nil in reload-package-autoloads

Slight optimization.
This commit is contained in:
Henrik Lissner 2018-06-10 20:54:32 +02:00
parent 2d5ac8a164
commit 5295f36115
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -201,39 +201,40 @@ This should be run whenever your `doom!' block or update your packages."
(with-temp-file doom-package-autoload-file (with-temp-file doom-package-autoload-file
(insert ";;; -*- lexical-binding:t -*-\n" (insert ";;; -*- lexical-binding:t -*-\n"
";; This file is autogenerated by `doom//reload-package-autoloads', DO NOT EDIT !!\n\n") ";; This file is autogenerated by `doom//reload-package-autoloads', DO NOT EDIT !!\n\n")
(save-excursion (let (case-fold-search)
;; Cache the important and expensive-to-initialize state here. (save-excursion
(doom-initialize-packages) ;; Cache the important and expensive-to-initialize state here.
(prin1 `(setq load-path ',load-path (doom-initialize-packages)
auto-mode-alist ',auto-mode-alist (prin1 `(setq load-path ',load-path
Info-directory-list ',Info-directory-list auto-mode-alist ',auto-mode-alist
doom-disabled-packages ',doom-disabled-packages Info-directory-list ',Info-directory-list
package-activated-list ',package-activated-list) doom-disabled-packages ',doom-disabled-packages
(current-buffer)) package-activated-list ',package-activated-list)
(print! (green "✓ Cached package state")) (current-buffer))
;; insert package autoloads (print! (green "✓ Cached package state"))
(dolist (spec package-alist) ;; insert package autoloads
(if-let* ((pkg (car spec)) (dolist (spec package-alist)
(desc (cadr spec))) (if-let* ((pkg (car spec))
(unless (memq pkg doom-autoload-excluded-packages) (desc (cadr spec)))
(let ((file (concat (package--autoloads-file-name desc) ".el"))) (unless (memq pkg doom-autoload-excluded-packages)
(when (file-exists-p file) (let ((file (concat (package--autoloads-file-name desc) ".el")))
(insert "(let ((load-file-name " (prin1-to-string (abbreviate-file-name file)) "))\n") (when (file-exists-p file)
(insert-file-contents file) (insert "(let ((load-file-name " (prin1-to-string (abbreviate-file-name file)) "))\n")
(while (re-search-forward "^\\(?:;;\\(.*\n\\)\\|\n\\)" nil t) (insert-file-contents file)
(unless (nth 8 (syntax-ppss)) (while (re-search-forward "^\\(?:;;\\(.*\n\\)\\|\n\\)" nil t)
(replace-match "" t t))) (unless (nth 8 (syntax-ppss))
(unless (bolp) (insert "\n")) (replace-match "" t t)))
(insert ")\n")))) (unless (bolp) (insert "\n"))
(print! (yellow "⚠ Couldn't find package desc for %s" (car spec)))))) (insert ")\n"))))
(print! (green "✓ Package autoloads included")) (print! (yellow "⚠ Couldn't find package desc for %s" (car spec))))))
;; Remove `load-path' and `auto-mode-alist' modifications (most of them, (print! (green "✓ Package autoloads included"))
;; at least); they are cached later, so all those membership checks are ;; Remove `load-path' and `auto-mode-alist' modifications (most of them,
;; unnecessary overhead. ;; at least); they are cached later, so all those membership checks are
(while (re-search-forward "^\\s-*\\((\\(?:add-to-list\\|\\(?:when\\|if\\) (boundp\\)\\s-+'\\(?:load-path\\|auto-mode-alist\\)\\)" nil t) ;; unnecessary overhead.
(goto-char (match-beginning 1)) (while (re-search-forward "^\\s-*\\((\\(?:add-to-list\\|\\(?:when\\|if\\) (boundp\\)\\s-+'\\(?:load-path\\|auto-mode-alist\\)\\)" nil t)
(kill-sexp)) (goto-char (match-beginning 1))
(print! (green "✓ Removed load-path/auto-mode-alist entries"))) (kill-sexp))
(print! (green "✓ Removed load-path/auto-mode-alist entries"))))
(doom--byte-compile-file doom-package-autoload-file) (doom--byte-compile-file doom-package-autoload-file)
(when (and noninteractive (not (daemonp))) (when (and noninteractive (not (daemonp)))
(doom--server-load doom-package-autoload-file)) (doom--server-load doom-package-autoload-file))