[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/flx 44951ac311 042/182: simplify caching
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/flx 44951ac311 042/182: simplify caching |
Date: |
Tue, 13 Dec 2022 03:59:23 -0500 (EST) |
branch: elpa/flx
commit 44951ac31148506a114225e8cc995b0dd35283f5
Author: Le Wang <le.wang@agworld.com.au>
Commit: Le Wang <le.wang@agworld.com.au>
simplify caching
---
flx-ido.el | 64 +++++++++++++++++++++++++++++---------------------------------
1 file changed, 30 insertions(+), 34 deletions(-)
diff --git a/flx-ido.el b/flx-ido.el
index 2927ac8076..e12725dc67 100644
--- a/flx-ido.el
+++ b/flx-ido.el
@@ -13,7 +13,7 @@
;; Version: 0.1
;; Last-Updated:
;; By:
-;; Update #: 34
+;; Update #: 35
;; URL:
;; Keywords:
;; Compatibility:
@@ -88,30 +88,32 @@ item, in which case, the ending items are deleted."
(defun flx-ido-narrowed (query items)
"Get the value from `flx-ido-narrowed-matches-hash' with the
longest prefix match."
- (let ((query-key (flx-ido-key-for-query query))
- best-match
- exact
- res)
- (loop for key being the hash-key of flx-ido-narrowed-matches-hash
- do (when (and (>= (length query-key) (length key))
- (eq t
- (compare-strings query-key 0 (min (length
query-key)
- (length key))
- key 0 nil))
- (or (null best-match)
- (> (length key) (length best-match))))
- (setq best-match key)
- (when (= (length key)
- (length query-key))
- (setq exact t)
- (return))))
- (setq res (cond (exact
- (gethash best-match flx-ido-narrowed-matches-hash))
- (best-match
- (flx-ido-undecorate (gethash best-match
flx-ido-narrowed-matches-hash)))
- (t
- (flx-ido-undecorate items))))
- (list exact res)))
+ (if (zerop (length query))
+ (list t (nreverse items))
+ (let ((query-key (flx-ido-key-for-query query))
+ best-match
+ exact
+ res)
+ (loop for key being the hash-key of flx-ido-narrowed-matches-hash
+ do (when (and (>= (length query-key) (length key))
+ (eq t
+ (compare-strings query-key 0 (min (length
query-key)
+ (length key))
+ key 0 nil))
+ (or (null best-match)
+ (> (length key) (length best-match))))
+ (setq best-match key)
+ (when (= (length key)
+ (length query-key))
+ (setq exact t)
+ (return))))
+ (setq res (cond (exact
+ (gethash best-match flx-ido-narrowed-matches-hash))
+ (best-match
+ (flx-ido-undecorate (gethash best-match
flx-ido-narrowed-matches-hash)))
+ (t
+ (flx-ido-undecorate items))))
+ (list exact res))))
(defun flx-ido-undecorate (strings)
(flx-ido-decorate strings t))
@@ -152,17 +154,11 @@ item, in which case, the ending items are deleted."
(defun flx-ido-match (query items)
"Better sorting for flx ido matching."
- (when (and (equal "" query)
- (not (gethash (flx-ido-key-for-query query)
- flx-ido-narrowed-matches-hash)))
- ;; original function reverses list.
- (setq items (nreverse (ido-delete-runs items)))
- (flx-ido-cache query items))
(destructuring-bind (exact res-items)
(flx-ido-narrowed query items)
- (if exact ; `ido-rotate' case is covered by exact
match
- res-items
- (flx-ido-cache query (flx-ido-match-internal query res-items)))))
+ (flx-ido-cache query (if exact
+ res-items
+ (flx-ido-match-internal query res-items)))))
(defvar flx-ido-use t
"Use flx matching for ido.")
- [nongnu] elpa/flx 9e7749e9e6 067/182: Merge pull request #27 from bbatsov/fix-capital-check, (continued)
- [nongnu] elpa/flx 9e7749e9e6 067/182: Merge pull request #27 from bbatsov/fix-capital-check, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 7424f54816 079/182: flx-ido: don't require cl; flx requires it anyway, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 3bcaf03434 002/182: add readme, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx bdfd9d98aa 014/182: add travis status image, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 6189f05c7e 004/182: add flx, ido implementation and helm experiment, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 4c67675437 032/182: add GC tuning information to README, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 114cf369cb 020/182: add ido installation instructions, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 7452ab1c79 021/182: README update, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx f566207c82 015/182: travis config update, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 01eef11b96 033/182: small efficiency fix, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 44951ac311 042/182: simplify caching,
ELPA Syncer <=
- [nongnu] elpa/flx cc3258bb10 038/182: cache key should be based on whole input, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 771f61f3fd 016/182: update test list, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx a792c2c5f1 053/182: change advice to before, fix comments, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 61dcc4f563 089/182: Reset caches on file reload., ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 24f5d2cfc5 099/182: Fix typo threshhold -> threshold, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx c45daa261c 124/182: refactor: pull out flx-get-matches-worker function, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx b9399afd48 136/182: Simplify math operations in score calculation, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 8419b1b28f 107/182: Bump version to v0.4 ., ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 46dd7d7edb 144/182: Improve readability, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 807d694555 154/182: remove reference to `flx-ido-big-demo`, ELPA Syncer, 2022/12/13