[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master e71e4d2 12/18: Speed up the default file sorting
From: |
Oleh Krehel |
Subject: |
[elpa] master e71e4d2 12/18: Speed up the default file sorting |
Date: |
Mon, 20 Apr 2015 12:39:06 +0000 |
branch: master
commit e71e4d21f5f9b5387667c1697cab3b87b2e14a76
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Speed up the default file sorting
* ivy.el (ivy-sort-file-function-default): Update.
(ivy--sorted-files): Update.
Turns out that calling `file-directory-p' in `cl-sort' is too expensive.
So when `ivy-sort-file-function' is `ivy-sort-file-function-default',
propertize all strings with whether they are directories or not.
When `ivy-sort-file-function' is something different,
e.g. `string-lessp', don't do propertizing since it also can be slow.
---
ivy.el | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/ivy.el b/ivy.el
index d52b4b9..3fa5d24 100644
--- a/ivy.el
+++ b/ivy.el
@@ -282,11 +282,11 @@ On error (read-only), call `ivy-on-del-error-function'."
(defun ivy-sort-file-function-default (x y)
"Compare two files X and Y.
Prioritize directories."
- (if (file-directory-p x)
- (if (file-directory-p y)
+ (if (get-text-property 0 'dirp x)
+ (if (get-text-property 0 'dirp y)
(string< x y)
t)
- (if (file-directory-p y)
+ (if (get-text-property 0 'dirp y)
nil
(string< x y))))
@@ -301,9 +301,12 @@ Directories come first."
(seq (all-completions "" 'read-file-name-internal)))
(if (equal dir "/")
seq
- (setq seq (cl-sort
- (delete "./" (delete "../" seq))
- ivy-sort-file-function))
+ (setq seq (delete "./" (delete "../" seq)))
+ (when (eq ivy-sort-file-function 'ivy-sort-file-function-default)
+ (setq seq (mapcar (lambda (x)
+ (propertize x 'dirp (file-directory-p x)))
+ (delete "./" (delete "../" seq)))))
+ (setq seq (cl-sort seq ivy-sort-file-function))
(dolist (dir ivy-extra-directories)
(push dir seq))
seq)))
- [elpa] master a9a4e81 05/18: counsel.el (counsel-git-grep): Fix the default-directory, (continued)
- [elpa] master a9a4e81 05/18: counsel.el (counsel-git-grep): Fix the default-directory, Oleh Krehel, 2015/04/20
- [elpa] master 539fe7d 07/18: ivy.el (ivy-completions): Fix an optimization, Oleh Krehel, 2015/04/20
- [elpa] master 23c0e6a 08/18: ivy.el (ivy-done): Update for non-matching file names, Oleh Krehel, 2015/04/20
- [elpa] master a94ca83 01/18: swiper.el: Add a work-around for window-start not being current, Oleh Krehel, 2015/04/20
- [elpa] master cafcfb9 10/18: Allow "C-." to jump to current symbol definition, Oleh Krehel, 2015/04/20
- [elpa] master d0f3826 11/18: ivy.el (ivy--preselect-index): Give priority to perfect match, Oleh Krehel, 2015/04/20
- [elpa] master 297008b 09/18: Allow to customize the file sorting order, Oleh Krehel, 2015/04/20
- [elpa] master 3282f78 13/18: Speed up the default file sorting even more, Oleh Krehel, 2015/04/20
- [elpa] master 525a19d 14/18: Propertize directories with ivy-subdir face, Oleh Krehel, 2015/04/20
- [elpa] master 10af5a6 16/18: ivy.el (ivy-done): Still expand "./" though, Oleh Krehel, 2015/04/20
- [elpa] master e71e4d2 12/18: Speed up the default file sorting,
Oleh Krehel <=
- [elpa] master 61a95c4 15/18: Don't expand the default when completing file names, Oleh Krehel, 2015/04/20
- [elpa] master efa18ec 17/18: swiper.el: Bump version, Oleh Krehel, 2015/04/20
- [elpa] master 2f4c2c1 18/18: Merge commit 'efa18eca10e5a0e05043f872cf9945842bb3a034' from swiper, Oleh Krehel, 2015/04/20