[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 5458f93 169/399: ivy.el (ivy--filter): Avoid a filter on e
From: |
Oleh Krehel |
Subject: |
[elpa] master 5458f93 169/399: ivy.el (ivy--filter): Avoid a filter on empty input |
Date: |
Sat, 20 Jul 2019 14:57:17 -0400 (EDT) |
branch: master
commit 5458f93acf1aa8e908eb2690b96058e53bbad01e
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
ivy.el (ivy--filter): Avoid a filter on empty input
Improves performance for large collections.
---
ivy.el | 78 ++++++++++++++++++++++++++++++++++--------------------------------
1 file changed, 40 insertions(+), 38 deletions(-)
diff --git a/ivy.el b/ivy.el
index fe1b865..dfe841c 100644
--- a/ivy.el
+++ b/ivy.el
@@ -3066,44 +3066,46 @@ Otherwise, the car must not match."
(defun ivy--filter (name candidates)
"Return all items that match NAME in CANDIDATES.
CANDIDATES are assumed to be static."
- (let ((re (funcall ivy--regex-function name)))
- (if (and
- ivy--old-re
- ivy--old-cands
- (equal re ivy--old-re))
- ;; quick caching for "C-n", "C-p" etc.
- ivy--old-cands
- (let* ((re-str (ivy-re-to-str re))
- (matcher (ivy-state-matcher ivy-last))
- (case-fold-search (ivy--case-fold-p name))
- (cands (cond
- ((and ivy--old-re
- (stringp re)
- (stringp ivy--old-re)
- (not (string-match-p "\\\\" ivy--old-re))
- (not (equal ivy--old-re ""))
- (memq (cl-search
- (if (string-match-p "\\\\)\\'" ivy--old-re)
- (substring ivy--old-re 0 -2)
- ivy--old-re)
- re)
- '(0 2)))
- (ivy--re-filter re ivy--old-cands))
- (matcher
- (funcall matcher re candidates))
- (t
- (ivy--re-filter re candidates)))))
- (if (memq (cdr (assq (ivy-state-caller ivy-last)
- ivy-index-functions-alist))
- '(ivy-recompute-index-swiper
- ivy-recompute-index-swiper-async))
- (progn
- (ivy--recompute-index name re-str cands)
- (setq ivy--old-cands (ivy--sort name cands)))
- (setq ivy--old-cands (ivy--sort name cands))
- (ivy--recompute-index name re-str ivy--old-cands))
- (setq ivy--old-re re)
- ivy--old-cands))))
+ (if (string= name "")
+ candidates
+ (let ((re (funcall ivy--regex-function name)))
+ (if (and
+ ivy--old-re
+ ivy--old-cands
+ (equal re ivy--old-re))
+ ;; quick caching for "C-n", "C-p" etc.
+ ivy--old-cands
+ (let* ((re-str (ivy-re-to-str re))
+ (matcher (ivy-state-matcher ivy-last))
+ (case-fold-search (ivy--case-fold-p name))
+ (cands (cond
+ ((and ivy--old-re
+ (stringp re)
+ (stringp ivy--old-re)
+ (not (string-match-p "\\\\" ivy--old-re))
+ (not (equal ivy--old-re ""))
+ (memq (cl-search
+ (if (string-match-p "\\\\)\\'"
ivy--old-re)
+ (substring ivy--old-re 0 -2)
+ ivy--old-re)
+ re)
+ '(0 2)))
+ (ivy--re-filter re ivy--old-cands))
+ (matcher
+ (funcall matcher re candidates))
+ (t
+ (ivy--re-filter re candidates)))))
+ (if (memq (cdr (assq (ivy-state-caller ivy-last)
+ ivy-index-functions-alist))
+ '(ivy-recompute-index-swiper
+ ivy-recompute-index-swiper-async))
+ (progn
+ (ivy--recompute-index name re-str cands)
+ (setq ivy--old-cands (ivy--sort name cands)))
+ (setq ivy--old-cands (ivy--sort name cands))
+ (ivy--recompute-index name re-str ivy--old-cands))
+ (setq ivy--old-re re)
+ ivy--old-cands)))))
(defun ivy--set-candidates (x)
"Update `ivy--all-candidates' with X."
- [elpa] master dceecd8 155/399: swiper.el (swiper-occur): Adapt to swiper-isearch, (continued)
- [elpa] master dceecd8 155/399: swiper.el (swiper-occur): Adapt to swiper-isearch, Oleh Krehel, 2019/07/20
- [elpa] master f38bb51 161/399: ivy.el (ivy--prompt-selectable-p): Allow to select "", Oleh Krehel, 2019/07/20
- [elpa] master 1b13ee8 162/399: ivy.el (ivy--use-selectable-prompt): Cache ivy--prompt-selected-p, Oleh Krehel, 2019/07/20
- [elpa] master 92ec03c 163/399: ivy-test.el (ivy-use-selectable-prompt): Add tests, Oleh Krehel, 2019/07/20
- [elpa] master b2693d1 160/399: counsel.el (counsel-locate-db-path): New defcustom, Oleh Krehel, 2019/07/20
- [elpa] master 44ea8b5 166/399: counsel.el (counsel-git-grep-cmd-function): Add, Oleh Krehel, 2019/07/20
- [elpa] master 502eae6 159/399: counsel.el (counsel--call): Rename to counsel--command, Oleh Krehel, 2019/07/20
- [elpa] master 115efb7 170/399: ivy.el (ivy--sorted-files): Work around all-completions returning $$, Oleh Krehel, 2019/07/20
- [elpa] master 6c858c1 168/399: ivy.el (ivy--filter): Improve performance with :matcher, Oleh Krehel, 2019/07/20
- [elpa] master ba849e5 173/399: ivy.el (ivy--re-filter): Fix for ivy--regex-ignore-order, Oleh Krehel, 2019/07/20
- [elpa] master 5458f93 169/399: ivy.el (ivy--filter): Avoid a filter on empty input,
Oleh Krehel <=
- [elpa] master 9c53320 174/399: swiper.el (swiper-isearch-function): Fix for strings with trailing \|, Oleh Krehel, 2019/07/20
- [elpa] master ce0a1f1 172/399: ivy.el (ivy--filter): Fix matcher not called on input "", Oleh Krehel, 2019/07/20
- [elpa] master 39759cf 180/399: ivy-test.el (ivy-with): Save current buffer, Oleh Krehel, 2019/07/20
- [elpa] master fa87b97 182/399: ivy-test.el: Print version, Oleh Krehel, 2019/07/20
- [elpa] master 8482f62 179/399: swiper.el (swiper-isearch-function): Fix str is " ", Oleh Krehel, 2019/07/20
- [elpa] master 482088c 178/399: swiper.el (swiper--avy-candidates): Fix for swiper-background-faces, Oleh Krehel, 2019/07/20
- [elpa] master 0e62f0d 185/399: counsel.el (counsel-switch-buffer-other-window): Update prompt, Oleh Krehel, 2019/07/20
- [elpa] master 5115df3 184/399: counsel.el: counsel-switch-buffer-other-window: new command., Oleh Krehel, 2019/07/20
- [elpa] master 0a12708 164/399: swiper.el: Add swiper background faces, Oleh Krehel, 2019/07/20
- [elpa] master 7e73580 171/399: ivy-test.el (counsel-find-file-with-dollars): Add test, Oleh Krehel, 2019/07/20