summaryrefslogtreecommitdiff
path: root/extensions
diff options
context:
space:
mode:
authorDaniel Mendler <mail@daniel-mendler.de>2025-04-06 00:01:54 +0200
committerDaniel Mendler <mail@daniel-mendler.de>2025-04-06 00:01:54 +0200
commitbb2aba7ffde4686d5875be27289fac89201018d2 (patch)
tree8c49e491b68ee99cc5ccffcf104d4744a565d444 /extensions
parent061d926d0f0eb2633416deeddc403a1a67b062ae (diff)
corfu-history--sort: Minor simplification
Diffstat (limited to 'extensions')
-rw-r--r--extensions/corfu-history.el9
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)