[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/flx a9f26b2840 138/182: Fix caching of nil
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/flx a9f26b2840 138/182: Fix caching of nil |
Date: |
Tue, 13 Dec 2022 03:59:37 -0500 (EST) |
branch: elpa/flx
commit a9f26b2840b872741a9da15fa420bde34bf326c8
Author: PythonNut <PythonNut@users.noreply.github.com>
Commit: PythonNut <PythonNut@users.noreply.github.com>
Fix caching of nil
---
flx.el | 90 +++++++++++++++++++++++++++++++++++++++---------------------------
1 file changed, 53 insertions(+), 37 deletions(-)
diff --git a/flx.el b/flx.el
index b51d5104c1..4b2a783a23 100644
--- a/flx.el
+++ b/flx.el
@@ -252,45 +252,57 @@ See documentation for logic."
match-cache
str-info
query)
- (let ((hash-key (+ q-index
- (* (or greater-than 0)
- query-length))))
- (or
- (gethash hash-key match-cache)
- (puthash
- hash-key
+ (let* ((hash-key (+ q-index
+ (* (or greater-than 0)
+ query-length)))
+ (hash-value (gethash hash-key match-cache)))
+ (if hash-value
+ (if (eq hash-value 'no-match)
+ nil
+ hash-value)
(let ((indexes (flx-bigger-sublist
- (gethash (aref query q-index) str-info)
- greater-than)))
+ (gethash (aref query q-index) str-info)
+ greater-than))
+ (match)
+ (score)
+ (best-score most-negative-fixnum))
+
(if (>= q-index (1- query-length))
- (mapcar (lambda (index)
- (cons (list index)
- (cons (aref heatmap index) 0))) indexes)
- (let ((match)
- (score)
- (best-score most-negative-fixnum))
- (dolist (index indexes (and match (list match)))
- (dolist (elem (flx-get-matches-worker index (1+ q-index)
- query-length heatmap
match-cache str-info query))
- (setq score (if (= (1- (caar elem)) index)
- (+ (cadr elem)
- (aref heatmap index)
- (* (min (cddr elem)
- 3)
- 15)
- 60)
+ (setq match (mapcar (lambda (index)
+ (cons (list index)
+ (cons (aref heatmap index) 0)))
+ indexes))
+ (dolist (index indexes)
+ (dolist (elem (flx-get-matches-worker index (1+ q-index)
+ query-length
+ heatmap
+ match-cache
+ str-info
+ query))
+ (setq score (if (= (1- (caar elem)) index)
(+ (cadr elem)
- (aref heatmap index))))
-
- ;; we only care about the optimal score
- (when (> score best-score)
- (setq best-score score
- match (cons (cons index (car elem))
- (cons score
- (if (= (1- (caar elem)) index)
- (1+ (cddr elem))
- 0))))))))))
- match-cache))))
+ (aref heatmap index)
+ (* (min (cddr elem)
+ 3)
+ 15)
+ 60)
+ (+ (cadr elem)
+ (aref heatmap index))))
+
+ ;; we only care about the optimal score
+ (when (> score best-score)
+ (setq best-score score
+ match (list (cons (cons index (car elem))
+ (cons score
+ (if (= (1- (caar elem))
+ index)
+ (1+ (cddr elem))
+ 0)))))))))
+
+ (puthash hash-key
+ (if match match 'no-match)
+ match-cache)
+ match))))
(defun flx-score (str query &optional cache)
"return best score matching QUERY against STR"
@@ -306,7 +318,11 @@ See documentation for logic."
;; Dynamic Programming table
(match-cache (make-hash-table :test 'eql :size 10))
(res (flx-get-matches-worker nil 0
- query-length heatmap match-cache
str-info query)))
+ query-length
+ heatmap
+ match-cache
+ str-info
+ query)))
;; postprocess candidate
(and res
(cons (if (and full-match-boost
- [nongnu] elpa/flx 3032920883 117/182: Fix search results changing positions as you type., (continued)
- [nongnu] elpa/flx 3032920883 117/182: Fix search results changing positions as you type., ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 46a1b29482 118/182: Merge pull request #62 from bsuh/fix61, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 5fe7f8a94a 121/182: Add algorithmic optimizations, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx b9c2d42b67 122/182: Remove deprecated tests, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 41842ff7b3 123/182: Small performance tweaks, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 9c8a17f199 127/182: cadar -> cl-cadar, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx ba2a503873 128/182: use Cask to manage deps, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 279179b5af 133/182: travis show pwd, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 321efc25da 132/182: fix Makefile circular dependency, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 4d625bdfb9 135/182: Test score before building possible match, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx a9f26b2840 138/182: Fix caching of nil,
ELPA Syncer <=
- [nongnu] elpa/flx aba36b564e 139/182: Rename flx-get-matches-worker, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 20e3fe8595 141/182: Make flx word separators customizable, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 8959c45907 147/182: Bump version, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 20e3073352 148/182: Merge pull request #78 from lewang/0.6, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx dd4b4d50da 149/182: Hotfix: Raise recursion limits dynamically, fixes #79, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 77e82ddd21 150/182: Move definition of flx-ido-mode to appease byte-compiler, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 7fce6a4cdb 153/182: Bump version, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx d633b6e14a 157/182: Set custom type of options, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 9c5cb5de02 158/182: Merge pull request #95 from emacsjanitors/silencio, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 7017d8416b 163/182: Add LICENSE file., ELPA Syncer, 2022/12/13