emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[nongnu] elpa/git-commit 8606488578 2/7: magit-save-repository-buffers:


From: ELPA Syncer
Subject: [nongnu] elpa/git-commit 8606488578 2/7: magit-save-repository-buffers: Rev-parse only once per directory
Date: Fri, 17 Mar 2023 19:59:47 -0400 (EDT)

branch: elpa/git-commit
commit 860648857875ca904c4b7b4678f7b8692296bb24
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>

    magit-save-repository-buffers: Rev-parse only once per directory
    
    Previously we called "git rev-parse --show-toplevel" once per buffer,
    but since the `default-directory' is the same for many of them, that
    needlessly repeated expensive work.
---
 lisp/magit-mode.el | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lisp/magit-mode.el b/lisp/magit-mode.el
index 2b69744069..c6ec10914c 100644
--- a/lisp/magit-mode.el
+++ b/lisp/magit-mode.el
@@ -1116,7 +1116,8 @@ argument (the prefix) non-nil means save all with no 
questions."
                    (with-current-buffer buffer
                      (setq magit-inhibit-refresh-save t)))
                  "to skip the current buffer and remember choice")
-             ,@save-some-buffers-action-alist)))
+             ,@save-some-buffers-action-alist))
+          (dirs nil))
       (save-some-buffers
        arg
        (lambda ()
@@ -1140,7 +1141,11 @@ argument (the prefix) non-nil means save all with no 
questions."
             ;; repositories, due to the required network access.
             ;;
             ;; Check whether the file is inside the repository.
-            (equal (magit-rev-parse-safe "--show-toplevel") topdir)
+            (equal (or (cdr (assoc default-directory dirs))
+                       (let ((dir (magit-rev-parse-safe "--show-toplevel")))
+                         (push (cons default-directory dir) dirs)
+                         dir))
+                   topdir)
             ;; Check whether the file is actually writable.
             (file-writable-p buffer-file-name))))))))
 



reply via email to

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