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

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

[elpa] externals/cape eeda77aa82 1/2: cape--cached-table: Add pointless


From: ELPA Syncer
Subject: [elpa] externals/cape eeda77aa82 1/2: cape--cached-table: Add pointless metadata bailout
Date: Thu, 22 Dec 2022 17:57:23 -0500 (EST)

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

    cape--cached-table: Add pointless metadata bailout
---
 cape.el | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/cape.el b/cape.el
index dfb1e7a95c..a98e44d74d 100644
--- a/cape.el
+++ b/cape.el
@@ -199,13 +199,21 @@ VALID is the input comparator, see `cape--input-valid-p'."
         (end (copy-marker end t))
         (table nil))
     (lambda (str pred action)
-      (let ((new-input (buffer-substring-no-properties beg end)))
-        (when (or (eq input 'init) (not (cape--input-valid-p input new-input 
valid)))
-          ;; NOTE: We have to make sure that the completion table is 
interruptible.
-          ;; An interruption should not happen between the setqs.
-          (setq table (funcall fun new-input)
-                input new-input)))
-      (complete-with-action action table str pred))))
+      ;; Bail out early for `metadata' and `boundaries'. This is a pointless
+      ;; move because of caching, but we do it anyway in the hope that the
+      ;; resulting profiler output looks less confusing, since the weight of 
the
+      ;; expensive FUN computation is moved to the `all-completions' action.
+      ;; Computing `all-completions' must surely be most expensive, so nobody
+      ;; will suspect a thing.
+      (unless (or (eq action 'metadata) (eq (car-safe action) 'boundaries))
+        (let ((new-input (buffer-substring-no-properties beg end)))
+          (when (or (eq input 'init)
+                    (not (cape--input-valid-p input new-input valid)))
+            ;; We have to make sure that the completion table is interruptible.
+            ;; An interruption should not happen between the setqs.
+            (setq table (funcall fun new-input)
+                  input new-input)))
+        (complete-with-action action table str pred)))))
 
 ;;;; Capfs
 



reply via email to

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