emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 316d3111a3: Don't update loaddefs.el timestamps uselessly in load


From: Lars Ingebrigtsen
Subject: master 316d3111a3: Don't update loaddefs.el timestamps uselessly in loaddefs-generate
Date: Fri, 12 Aug 2022 14:22:42 -0400 (EDT)

branch: master
commit 316d3111a3666237caf86808d53765c8c77a3f53
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Don't update loaddefs.el timestamps uselessly in loaddefs-generate
    
    * lisp/emacs-lisp/loaddefs-gen.el (loaddefs-generate): Don't
    re-write the loaddefs.el file when there's no reason to.
---
 lisp/emacs-lisp/loaddefs-gen.el | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/lisp/emacs-lisp/loaddefs-gen.el b/lisp/emacs-lisp/loaddefs-gen.el
index 0c9bc4832b..6cb5d00782 100644
--- a/lisp/emacs-lisp/loaddefs-gen.el
+++ b/lisp/emacs-lisp/loaddefs-gen.el
@@ -589,7 +589,8 @@ instead of just updating them with the new/changed 
autoloads."
       ;; We have some data, so generate the loaddef files.  First
       ;; group per output file.
       (dolist (fdefs (seq-group-by #'car defs))
-        (let ((loaddefs-file (car fdefs)))
+        (let ((loaddefs-file (car fdefs))
+              hash)
           (with-temp-buffer
             (if (and updating (file-exists-p loaddefs-file))
                 (insert-file-contents loaddefs-file)
@@ -599,6 +600,7 @@ instead of just updating them with the new/changed 
autoloads."
               (when extra-data
                 (insert extra-data)
                 (ensure-empty-lines 1)))
+            (setq hash (buffer-hash))
             ;; Then group by source file (and sort alphabetically).
             (dolist (section (sort (seq-group-by #'cadr (cdr fdefs))
                                    (lambda (e1 e2)
@@ -635,9 +637,11 @@ instead of just updating them with the new/changed 
autoloads."
                     (loaddefs-generate--print-form def))
                   (unless (bolp)
                     (insert "\n")))))
-            (write-region (point-min) (point-max) loaddefs-file nil 'silent)
-            (byte-compile-info (file-relative-name loaddefs-file 
lisp-directory)
-                               t "GEN")))))))
+            ;; Only write the file if we actually made a change.
+            (unless (equal (buffer-hash) hash)
+              (write-region (point-min) (point-max) loaddefs-file nil 'silent)
+              (byte-compile-info
+               (file-relative-name loaddefs-file lisp-directory) t 
"GEN"))))))))
 
 (defun loaddefs-generate--print-form (def)
   "Print DEF in a format that makes sense for version control."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]