branch: externals/corfu commit bb2aba7ffde4686d5875be27289fac89201018d2 Author: Daniel Mendler <m...@daniel-mendler.de> Commit: Daniel Mendler <m...@daniel-mendler.de>
corfu-history--sort: Minor simplification --- extensions/corfu-history.el | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/extensions/corfu-history.el b/extensions/corfu-history.el index c14a0dfb43..0012d6f9c9 100644 --- a/extensions/corfu-history.el +++ b/extensions/corfu-history.el @@ -62,13 +62,8 @@ or the property `history-length' of `corfu-history'.") (cl-loop for elem in corfu-history for index from 0 do (unless (gethash elem corfu-history--hash) (puthash elem index corfu-history--hash)))) - ;; Decorate each candidate with (index<<13) + length. This way we sort first by index and then by - ;; length. We assume that the candidates are shorter than 2**13 characters and that the history is - ;; shorter than 2**16 entries. - (cl-loop for cand on cands do - (setcar cand (cons (car cand) - (+ (ash (gethash (car cand) corfu-history--hash #xFFFF) 13) - (length (car cand)))))) + (cl-loop for max = most-positive-fixnum for cand on cands do + (setcar cand (cons (car cand) (gethash (car cand) corfu-history--hash max)))) (setq cands (sort cands #'corfu-history--sort-predicate)) (cl-loop for cand on cands do (setcar cand (caar cand))) cands)