emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/cape 913f68859d: cape-super-capf: Get rid of caching


From: ELPA Syncer
Subject: [elpa] externals/cape 913f68859d: cape-super-capf: Get rid of caching
Date: Fri, 10 Jun 2022 05:57:24 -0400 (EDT)

branch: externals/cape
commit 913f68859d0cf6a02a71ddde48bc8454564a2efd
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    cape-super-capf: Get rid of caching
    
    The caching should be unnecessary.
---
 cape.el | 48 ++++++++++++++++++++++--------------------------
 1 file changed, 22 insertions(+), 26 deletions(-)

diff --git a/cape.el b/cape.el
index c54e5def15..6d39c05674 100644
--- a/cape.el
+++ b/cape.el
@@ -521,13 +521,11 @@ If INTERACTIVE is nil the function acts like a Capf."
   (lambda ()
     (when-let (results (delq nil (mapcar #'funcall capfs)))
       (pcase-let* ((`((,beg ,end . ,_)) results)
-                   (cache-candidates nil)
-                   (cache-filter nil)
-                   (cache-ht (make-hash-table :test #'equal))
+                   (cand-ht (make-hash-table :test #'equal))
                    (extra-fun
                     (lambda (prop)
                       (lambda (cand &rest args)
-                        (when-let (fun (plist-get (gethash cand cache-ht) 
prop))
+                        (when-let (fun (plist-get (gethash cand cand-ht) prop))
                           (apply fun cand args)))))
                    (tables nil)
                    (prefix-len nil))
@@ -552,28 +550,26 @@ If INTERACTIVE is nil the function acts like a Capf."
                               (display-sort-function . identity)
                               (cycle-sort-function . identity)))
                   ('t
-                   (let ((filter (list str (copy-sequence 
completion-regexp-list) completion-ignore-case)))
-                     (unless (equal filter cache-filter)
-                       (let ((ht (make-hash-table :test #'equal))
-                             (candidates nil))
-                         (cl-loop for (table . plist) in tables do
-                                  (let* ((pr (plist-get plist :predicate))
-                                         (md (completion-metadata "" table pr))
-                                         (sort (or (completion-metadata-get md 
'display-sort-function)
-                                                   #'identity))
-                                         (cands (funcall sort (all-completions 
str table pr))))
-                                    (cl-loop for cell on cands
-                                             for cand = (car cell) do
-                                             (if (eq (gethash cand ht t) t)
-                                                 (puthash cand plist ht)
-                                               (setcar cell nil)))
-                                    (setq candidates (nconc candidates 
cands))))
-                         (setq cache-filter filter
-                               cache-candidates (delq nil candidates)
-                               cache-ht ht))))
-                   (if pred
-                       (cl-loop for x in cache-candidates if (funcall pred x) 
collect x)
-                     (copy-sequence cache-candidates)))
+                   (let ((ht (make-hash-table :test #'equal))
+                         (candidates nil))
+                     (cl-loop for (table . plist) in tables do
+                              (let* ((pr (if-let (pr (plist-get plist 
:predicate))
+                                             (if pred
+                                                 (lambda (x) (and (funcall 
pred x) (funcall pr x)))
+                                               pr)
+                                           pred))
+                                     (md (completion-metadata "" table pr))
+                                     (sort (or (completion-metadata-get md 
'display-sort-function)
+                                               #'identity))
+                                     (cands (funcall sort (all-completions str 
table pr))))
+                                (cl-loop for cell on cands
+                                         for cand = (car cell) do
+                                         (if (eq (gethash cand ht t) t)
+                                             (puthash cand plist ht)
+                                           (setcar cell nil)))
+                                (setq candidates (nconc candidates cands))))
+                     (setq cand-ht ht)
+                     candidates))
                   (_
                    (completion--some
                     (pcase-lambda (`(,table . ,plist))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]