aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Gutov2019-12-21 00:07:08 +0200
committerDmitry Gutov2019-12-21 00:12:44 +0200
commit2c8f1539ab0a2d8b6b2bb9982249c5aa2dbd27b1 (patch)
treeb00c2ec2c4cdef4381195b03ae2c501e63536ec1
parent52178a312d34512f7db53ae34ea7f815b5a13323 (diff)
downloademacs-2c8f1539ab0a2d8b6b2bb9982249c5aa2dbd27b1.tar.gz
emacs-2c8f1539ab0a2d8b6b2bb9982249c5aa2dbd27b1.zip
Speed up vc-dir-update
* lisp/vc/vc-dir.el (vc-dir-update): Speed up. (https://lists.gnu.org/archive/html/emacs-devel/2019-12/msg00568.html)
-rw-r--r--lisp/vc/vc-dir.el27
1 files changed, 15 insertions, 12 deletions
diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el
index e2259785923..ad25e8aa537 100644
--- a/lisp/vc/vc-dir.el
+++ b/lisp/vc/vc-dir.el
@@ -390,19 +390,22 @@ If NOINSERT, ignore elements on ENTRIES which are not in the ewoc."
390 ;; We assume the ewoc is sorted too, which should be the 390 ;; We assume the ewoc is sorted too, which should be the
391 ;; case if we always add entries with vc-dir-update. 391 ;; case if we always add entries with vc-dir-update.
392 (setq entries 392 (setq entries
393 (let ((entry-dirs
394 (mapcar (lambda (entry)
395 (cons (file-name-directory
396 (directory-file-name (expand-file-name (car entry))))
397 entry))
398 entries)))
393 ;; Sort: first files and then subdirectories. 399 ;; Sort: first files and then subdirectories.
394 ;; XXX: this is VERY inefficient, it computes the directory 400 (mapcar #'cdr
395 ;; names too many times 401 (sort entry-dirs
396 (sort entries 402 (lambda (pair1 pair2)
397 (lambda (entry1 entry2) 403 (let ((dir1 (car pair1))
398 (let ((dir1 (file-name-directory 404 (dir2 (car pair2)))
399 (directory-file-name (expand-file-name (car entry1))))) 405 (cond
400 (dir2 (file-name-directory 406 ((string< dir1 dir2) t)
401 (directory-file-name (expand-file-name (car entry2)))))) 407 ((not (string= dir1 dir2)) nil)
402 (cond 408 ((string< (cadr pair1) (cadr pair2))))))))))
403 ((string< dir1 dir2) t)
404 ((not (string= dir1 dir2)) nil)
405 ((string< (car entry1) (car entry2))))))))
406 ;; Insert directory entries in the right places. 409 ;; Insert directory entries in the right places.
407 (let ((entry (car entries)) 410 (let ((entry (car entries))
408 (node (ewoc-nth vc-ewoc 0)) 411 (node (ewoc-nth vc-ewoc 0))