]> git.eshelyaron.com Git - emacs.git/commitdiff
lisp/custom.el (load-theme): Only compute hash when needed
authorMark Oteiza <mvoteiza@udel.edu>
Sun, 13 Sep 2015 18:12:22 +0000 (14:12 -0400)
committerMark Oteiza <mvoteiza@udel.edu>
Tue, 15 Sep 2015 15:11:16 +0000 (11:11 -0400)
lisp/custom.el

index ea5ab7a4773ba7d89197c60ced6ceab55f211ed2..e212e32807dfc810243495849d568dfdf920e003 100644 (file)
@@ -1214,13 +1214,11 @@ Return t if THEME was successfully loaded, nil otherwise."
     (put theme 'theme-documentation nil))
   (let ((fn (locate-file (concat (symbol-name theme) "-theme.el")
                         (custom-theme--load-path)
-                        '("" "c")))
-       hash)
+                        '("" "c"))))
     (unless fn
       (error "Unable to find theme file for `%s'" theme))
     (with-temp-buffer
       (insert-file-contents fn)
-      (setq hash (secure-hash 'sha256 (current-buffer)))
       ;; Check file safety with `custom-safe-themes', prompting the
       ;; user if necessary.
       (when (or no-confirm
@@ -1228,8 +1226,9 @@ Return t if THEME was successfully loaded, nil otherwise."
                (and (memq 'default custom-safe-themes)
                     (equal (file-name-directory fn)
                            (expand-file-name "themes/" data-directory)))
-               (member hash custom-safe-themes)
-               (custom-theme-load-confirm hash))
+                (let ((hash (secure-hash 'sha256 (current-buffer))))
+                  (or (member hash custom-safe-themes)
+                      (custom-theme-load-confirm hash))))
        (let ((custom--inhibit-theme-enable t)
               (buffer-file-name fn))    ;For load-history.
          (eval-buffer))