diff options
| author | Daniel Mendler <mail@daniel-mendler.de> | 2024-02-14 22:02:53 +0100 |
|---|---|---|
| committer | Daniel Mendler <mail@daniel-mendler.de> | 2024-02-14 22:06:05 +0100 |
| commit | f6fe5e17e6c9c26801b26d8a1b77642592f42906 (patch) | |
| tree | 6f8ce3f495ea5678c9a40a4441094fe0a2354e07 | |
| parent | b24748093b00b37c3a572c4909f61c08fa27504f (diff) | |
Optimize orderless-try-completion predicate calling convention
Only allocate a rest argument list if the predicate is used on hash table
candidates.
| -rw-r--r-- | orderless.el | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/orderless.el b/orderless.el index e914a6b..a55c628 100644 --- a/orderless.el +++ b/orderless.el @@ -472,15 +472,15 @@ This function is part of the `orderless' completion style." ;; called more than two times. (orderless-filter string table - ;; key/value for hash tables - (lambda (&rest args) - (when (or (not pred) (apply pred args)) - (setq args (car args) ;; first argument is key - args (if (consp args) (car args) args) ;; alist - args (if (symbolp args) (symbol-name args) args)) - (when (and one (not (equal one args))) + (lambda (arg &rest val) ;; val for hash table + (when (or (not pred) (if val (funcall pred arg (car val)) (funcall pred arg))) + ;; Normalize predicate argument + (setq arg (if (consp arg) (car arg) arg) ;; alist + arg (if (symbolp arg) (symbol-name arg) arg)) ;; symbols + ;; Check if there is more than a single match (= many). + (when (and one (not (equal one arg))) (throw 'orderless--many (cons string point))) - (setq one args) + (setq one arg) t))) (when one ;; Prepend prefix if the candidate does not already have the same |
