From ea7aee894dd113d92a2f800d40b665b239376f5d Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Thu, 14 Aug 2025 14:50:09 +0100 Subject: [PATCH] vc-buffer-sync-fileset: Reorder some checks for speed (bug#79137) * lisp/vc/vc.el (vc-buffer-sync-fileset): Check whether a buffer's file is in one of our directories before checking whether it exists on disk. This should mean far fewer system calls overall (bug#79137). --- lisp/vc/vc.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index f2972f10e6a..5d8c3f1eeb8 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -2506,14 +2506,15 @@ buffers whose files exist on disk. Otherwise it syncs all of them." (lambda (buf) (and-let* ((file (buffer-local-value 'buffer-file-name buf)) - ((or missing-in-dirs (file-exists-p file))) ((cl-some (if not-essential (lambda (dir) ;; For speed (bug#79137). (string-prefix-p dir file)) (lambda (dir) (file-in-directory-p file dir))) - dirs))))))))) + dirs)) + ((or missing-in-dirs + (file-exists-p file)))))))))) (dolist (buf buffers) (with-current-buffer buf (vc-buffer-sync not-essential)))))