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

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

[elpa] externals/orderless 9c1b276fe4 193/204: Optimize orderless-try-co


From: ELPA Syncer
Subject: [elpa] externals/orderless 9c1b276fe4 193/204: Optimize orderless-try-completion
Date: Tue, 11 Jan 2022 12:58:30 -0500 (EST)

branch: externals/orderless
commit 9c1b276fe43a3de177470f84ddf315ae5f2221e6
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    Optimize orderless-try-completion
---
 orderless.el | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/orderless.el b/orderless.el
index a458f329d5..9250756688 100644
--- a/orderless.el
+++ b/orderless.el
@@ -458,17 +458,24 @@ match, it completes to that match.  If there are no 
matches, it
 returns nil.  In any other case it \"completes\" STRING to
 itself, without moving POINT.
 This function is part of the `orderless' completion style."
-  (let ((all (orderless-filter string table pred)))
-    (cond
-     ((null all) nil)
-     ((null (cdr all))
-      (if (equal string (car all))
-          t                             ; unique exact match
-        (let ((full (concat
-                     (car (orderless--prefix+pattern string table pred))
-                     (car all))))
-          (cons full (length full)))))
-     (t (cons string point)))))
+  (catch 'orderless--many
+    (let (one)
+      ;; Abuse all-completions/orderless-filter as a fast search loop.
+      ;; Should be more or less allocation-free since our "predicate"
+      ;; always returns nil.
+      (orderless-filter string table
+                        (lambda (str)
+                          (when (or (not pred) (funcall pred str))
+                            (when one
+                              (throw 'orderless--many (cons string point)))
+                            (setq one str))
+                          nil))
+      (when one
+        (if (equal string one)
+            t ;; unique exact match
+          (setq one (concat (car (orderless--prefix+pattern string table pred))
+                            one))
+          (cons one (length one)))))))
 
 ;;;###autoload
 (add-to-list 'completion-styles-alist



reply via email to

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