[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/flx 41842ff7b3 123/182: Small performance tweaks
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/flx 41842ff7b3 123/182: Small performance tweaks |
Date: |
Tue, 13 Dec 2022 03:59:36 -0500 (EST) |
branch: elpa/flx
commit 41842ff7b33c35104aca6647eb4a944a5d73a365
Author: PythonNut <PythonNut@users.noreply.github.com>
Commit: PythonNut <PythonNut@users.noreply.github.com>
Small performance tweaks
---
flx.el | 73 ++++++++++++++++++++++++++++++++----------------------------------
1 file changed, 35 insertions(+), 38 deletions(-)
diff --git a/flx.el b/flx.el
index 26b397fe14..0d37dbb9cd 100644
--- a/flx.el
+++ b/flx.el
@@ -258,19 +258,22 @@ See documentation for logic."
(> query-length 1)))
;; Dynamic Programming table
- (match-cache (make-hash-table :test 'equal :size 10))
+ (match-cache (make-hash-table :test 'eql :size 10))
- ;; local variables to be used later
- (best-score most-negative-fixnum)
+ ;; local variable to be used later
(indexes nil)
+ (hash-key 0)
((symbol-function #'flx-get-matches-worker)
(lambda (greater-than q-index)
(or
(gethash
- (cons greater-than q-index) match-cache)
+ (setq hash-key (+ q-index
+ (* (or greater-than 0)
+ query-length)))
+ match-cache)
(puthash
- (cons greater-than q-index)
+ hash-key
(progn
(setq indexes (flx-bigger-sublist
(gethash (aref query q-index) hash)
@@ -279,45 +282,39 @@ See documentation for logic."
(mapcar (lambda (index)
(cons (list index)
(cons (aref heatmap index) 0))) indexes)
- (let ((matches) (duplicate-scores most-negative-fixnum))
- (dolist (index indexes matches)
- (dolist (elem
- (mapcar
- (lambda (object)
- (cons (cons index (car object))
- (cons
- (+ (car (cdr object))
- (aref heatmap index)
- (if (= (1- (caar object)) index)
- (+ (* (min (1+ (cddr object))
- 4)
- 15)
- 45)
- 0)
- (if (and full-match-boost
- (= (1+ (length
- (car object)))
- (length str)))
- 10000
- 0))
- (if (= (1- (caar object)) index)
- (1+ (cddr object))
- 0))))
-
- (flx-get-matches-worker index (1+ q-index))))
-
+ (let ((match) (best-score most-negative-fixnum))
+ (dolist (index indexes (and match (list match)))
+ (dolist (elem (flx-get-matches-worker index (1+
q-index)))
+ (setq elem
+ (cons (cons index (car elem))
+ (cons
+ (+ (cadr elem)
+ (aref heatmap index)
+ (if (= (1- (caar elem)) index)
+ (+ (* (min (cddr elem)
+ 3)
+ 15)
+ 60)
+ 0))
+ (if (= (1- (caar elem)) index)
+ (1+ (cddr elem))
+ 0))))
;; we only care about the optimal score
- (when (> (car (cdr elem))
- duplicate-scores)
- (setq duplicate-scores (car (cdr elem)))
- (push elem matches)))))))
+ (when (> (cadr elem) best-score)
+ (setq best-score (cadr elem)
+ match elem)))))))
match-cache)))))
;; postprocess candidate
(let ((res (flx-get-matches-worker nil 0)))
(and res
- (cons (car (cdr (car res)))
- (car (car res))))))))
+ (cons (+ (cadar res)
+ (if (and full-match-boost
+ (= (length (caar res))
+ (length str)))
+ 10000
+ 0))
+ (caar res)))))))
(defun flx-propertize (obj score &optional add-score)
"Return propertized copy of obj according to score.
- [nongnu] elpa/flx 3d631fdd38 101/182: Improve behaviour backspacing flx -> flex., (continued)
- [nongnu] elpa/flx 3d631fdd38 101/182: Improve behaviour backspacing flx -> flex., ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx c75f14fbc2 104/182: Fix docstring bugs from checkdoc., ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 6797797426 105/182: Update status in README.md., ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx a154058007 108/182: Use ido's name canonicalization., ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx acd4334893 109/182: Increase threshold to 2000., ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx a59c08283d 110/182: Simplify caching, implement own flex., ELPA Syncer, 2022/12/13
- [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 <=
- [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, 2022/12/13
- [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