summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorDmitry Gutov <dgutov@yandex.ru>2019-12-21 00:07:08 +0200
committerDmitry Gutov <dgutov@yandex.ru>2019-12-21 00:12:44 +0200
commit2c8f1539ab0a2d8b6b2bb9982249c5aa2dbd27b1 (patch)
treeb00c2ec2c4cdef4381195b03ae2c501e63536ec1 /lisp
parent52178a312d34512f7db53ae34ea7f815b5a13323 (diff)
downloademacs-2c8f1539ab0a2d8b6b2bb9982249c5aa2dbd27b1.tar.gz
emacs-2c8f1539ab0a2d8b6b2bb9982249c5aa2dbd27b1.tar.bz2
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)
Diffstat (limited to 'lisp')
-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."
;; We assume the ewoc is sorted too, which should be the
;; case if we always add entries with vc-dir-update.
(setq entries
+ (let ((entry-dirs
+ (mapcar (lambda (entry)
+ (cons (file-name-directory
+ (directory-file-name (expand-file-name (car entry))))
+ entry))
+ entries)))
;; Sort: first files and then subdirectories.
- ;; XXX: this is VERY inefficient, it computes the directory
- ;; names too many times
- (sort entries
- (lambda (entry1 entry2)
- (let ((dir1 (file-name-directory
- (directory-file-name (expand-file-name (car entry1)))))
- (dir2 (file-name-directory
- (directory-file-name (expand-file-name (car entry2))))))
- (cond
- ((string< dir1 dir2) t)
- ((not (string= dir1 dir2)) nil)
- ((string< (car entry1) (car entry2))))))))
+ (mapcar #'cdr
+ (sort entry-dirs
+ (lambda (pair1 pair2)
+ (let ((dir1 (car pair1))
+ (dir2 (car pair2)))
+ (cond
+ ((string< dir1 dir2) t)
+ ((not (string= dir1 dir2)) nil)
+ ((string< (cadr pair1) (cadr pair2))))))))))
;; Insert directory entries in the right places.
(let ((entry (car entries))
(node (ewoc-nth vc-ewoc 0))