diff options
| author | Daniel Mendler <mail@daniel-mendler.de> | 2025-04-06 00:01:54 +0200 |
|---|---|---|
| committer | Daniel Mendler <mail@daniel-mendler.de> | 2025-04-06 00:01:54 +0200 |
| commit | bb2aba7ffde4686d5875be27289fac89201018d2 (patch) | |
| tree | 8c49e491b68ee99cc5ccffcf104d4744a565d444 /extensions | |
| parent | 061d926d0f0eb2633416deeddc403a1a67b062ae (diff) | |
corfu-history--sort: Minor simplification
Diffstat (limited to 'extensions')
| -rw-r--r-- | extensions/corfu-history.el | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/extensions/corfu-history.el b/extensions/corfu-history.el index c14a0df..0012d6f 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) |
