emacs-diffs
[Top][All Lists]
Advanced

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

master a4c27ce 1/2: Improve performance of auto-revert-notify-add-watch


From: Michael Albinus
Subject: master a4c27ce 1/2: Improve performance of auto-revert-notify-add-watch
Date: Thu, 3 Dec 2020 09:58:59 -0500 (EST)

branch: master
commit a4c27ceb50daea3488517cc729350e734484649f
Author: Spencer Baugh <sbaugh@catern.com>
Commit: Michael Albinus <michael.albinus@gmx.de>

    Improve performance of auto-revert-notify-add-watch
    
    * 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 | 29 +++++++----------------------
 1 file changed, 7 insertions(+), 22 deletions(-)

diff --git a/lisp/autorevert.el b/lisp/autorevert.el
index 046ea2b..d5bb75c 100644
--- a/lisp/autorevert.el
+++ b/lisp/autorevert.el
@@ -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



reply via email to

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