]> git.eshelyaron.com Git - emacs.git/commitdiff
Improve performance of auto-revert-notify-add-watch
authorSpencer Baugh <sbaugh@catern.com>
Thu, 3 Dec 2020 14:57:20 +0000 (15:57 +0100)
committerMichael Albinus <michael.albinus@gmx.de>
Thu, 3 Dec 2020 14:57:20 +0000 (15:57 +0100)
* lisp/autorevert.el (auto-revert-notify-add-watch):
Do not search for buffers registered with the same file name, this
is not necessary.  (Bug#44638)

lisp/autorevert.el

index 046ea2b5d6a5bd132ed2f8ecdc2e58b65a5cd9a5..d5bb75c2f1e0885dbcf94c15cca587c401a23044 100644 (file)
@@ -650,30 +650,15 @@ will use an up-to-date value of `auto-revert-interval'."
               (string-match auto-revert-notify-exclude-dir-regexp
                            (expand-file-name default-directory))
              (file-symlink-p (or buffer-file-name default-directory)))
-    ;; Check, whether this has been activated already.
     (let ((file (if buffer-file-name
                    (expand-file-name buffer-file-name default-directory)
                  (expand-file-name default-directory))))
-      (maphash
-       (lambda (key _value)
-         (when (and
-                (file-notify-valid-p key)
-                (equal (file-notify--watch-absolute-filename
-                        (gethash key file-notify-descriptors))
-                       (directory-file-name file))
-                (equal (file-notify--watch-callback
-                        (gethash key file-notify-descriptors))
-                       'auto-revert-notify-handler))
-         (setq auto-revert-notify-watch-descriptor key)))
-       auto-revert--buffers-by-watch-descriptor)
-      ;; Create a new watch if needed.
-      (unless auto-revert-notify-watch-descriptor
-        (setq auto-revert-notify-watch-descriptor
-             (ignore-errors
-               (file-notify-add-watch
-                file
-                 (if buffer-file-name '(change attribute-change) '(change))
-                 'auto-revert-notify-handler))))
+      (setq auto-revert-notify-watch-descriptor
+           (ignore-errors
+             (file-notify-add-watch
+              file
+               (if buffer-file-name '(change attribute-change) '(change))
+               'auto-revert-notify-handler))))
       (when auto-revert-notify-watch-descriptor
         (setq auto-revert-notify-modified-p t)
         (puthash
@@ -682,7 +667,7 @@ will use an up-to-date value of `auto-revert-interval'."
               (gethash auto-revert-notify-watch-descriptor
                        auto-revert--buffers-by-watch-descriptor))
          auto-revert--buffers-by-watch-descriptor)
-        (add-hook 'kill-buffer-hook #'auto-revert-notify-rm-watch nil t)))))
+        (add-hook 'kill-buffer-hook #'auto-revert-notify-rm-watch nil t))))
 
 ;; If we have file notifications, we want to update the auto-revert buffers
 ;; immediately when a notification occurs. Since file updates can happen very