From f6fe5e17e6c9c26801b26d8a1b77642592f42906 Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Wed, 14 Feb 2024 22:02:53 +0100 Subject: Optimize orderless-try-completion predicate calling convention Only allocate a rest argument list if the predicate is used on hash table candidates. --- orderless.el | 16 ++++++++-------- 1 file 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 -- cgit v1.0