emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master b000b0a 007/399: ivy.el (ivy--recompute-index): Speed up


From: Oleh Krehel
Subject: [elpa] master b000b0a 007/399: ivy.el (ivy--recompute-index): Speed up
Date: Sat, 20 Jul 2019 14:56:37 -0400 (EDT)

branch: master
commit b000b0a13f22efbe75b26399c35f944001e5e973
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    ivy.el (ivy--recompute-index): Speed up
    
    Return 0 immediately if `name' is empty.
---
 ivy.el | 64 +++++++++++++++++++++++++++++++++-------------------------------
 1 file changed, 33 insertions(+), 31 deletions(-)

diff --git a/ivy.el b/ivy.el
index e73d258..208d35b 100644
--- a/ivy.el
+++ b/ivy.el
@@ -3156,37 +3156,39 @@ RE-STR is the regexp, CANDS are the current candidates."
         (empty (string= name "")))
     (unless (eq this-command 'ivy-resume)
       (ivy-set-index
-       (or
-        (cl-position (ivy--remove-prefix "^" name)
-                     cands
-                     :test #'ivy--case-fold-string=)
-        (and ivy--directory
-             (cl-position (concat re-str "/")
-                          cands
-                          :test #'ivy--case-fold-string=))
-        (and (eq caller 'ivy-switch-buffer)
-             (not empty)
-             0)
-        (and (not empty)
-             (not (eq caller 'swiper))
-             (not (and ivy--flx-featurep
-                       (eq ivy--regex-function 'ivy--regex-fuzzy)
-                       ;; Limit to 200 candidates
-                       (null (nthcdr 200 cands))))
-             ;; If there was a preselected candidate, don't try to
-             ;; keep it selected even if the regexp still matches it.
-             ;; See issue #1563.  See also `ivy--preselect-index',
-             ;; which this logic roughly mirrors.
-             (not (or
-                   (and (integerp preselect)
-                        (= ivy--index preselect))
-                   (equal current preselect)
-                   (and (stringp preselect)
-                        (stringp current)
-                        (string-match-p preselect current))))
-             ivy--old-cands
-             (cl-position current cands :test #'equal))
-        (funcall func re-str cands))))
+       (if (string= name "")
+           0
+         (or
+          (cl-position (ivy--remove-prefix "^" name)
+                       cands
+                       :test #'ivy--case-fold-string=)
+          (and ivy--directory
+               (cl-position (concat re-str "/")
+                            cands
+                            :test #'ivy--case-fold-string=))
+          (and (eq caller 'ivy-switch-buffer)
+               (not empty)
+               0)
+          (and (not empty)
+               (not (eq caller 'swiper))
+               (not (and ivy--flx-featurep
+                         (eq ivy--regex-function 'ivy--regex-fuzzy)
+                         ;; Limit to 200 candidates
+                         (null (nthcdr 200 cands))))
+               ;; If there was a preselected candidate, don't try to
+               ;; keep it selected even if the regexp still matches it.
+               ;; See issue #1563.  See also `ivy--preselect-index',
+               ;; which this logic roughly mirrors.
+               (not (or
+                     (and (integerp preselect)
+                          (= ivy--index preselect))
+                     (equal current preselect)
+                     (and (stringp preselect)
+                          (stringp current)
+                          (string-match-p preselect current))))
+               ivy--old-cands
+               (cl-position current cands :test #'equal))
+          (funcall func re-str cands)))))
     (when (or empty (string= name "^"))
       (ivy-set-index
        (or (ivy--preselect-index preselect cands)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]