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

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

[nongnu] elpa/haskell-tng-mode 8bb3c34 363/385: the in-memory cache does


From: ELPA Syncer
Subject: [nongnu] elpa/haskell-tng-mode 8bb3c34 363/385: the in-memory cache doesn't have to cache nil
Date: Wed, 6 Oct 2021 00:00:05 -0400 (EDT)

branch: elpa/haskell-tng-mode
commit 8bb3c344c747b7f1ebda9aca3bb6c4196da45c4b
Author: Tseen She <ts33n.sh3@gmail.com>
Commit: Tseen She <ts33n.sh3@gmail.com>

    the in-memory cache doesn't have to cache nil
---
 haskell-tng-util.el | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/haskell-tng-util.el b/haskell-tng-util.el
index 75f4b01..28e3d75 100644
--- a/haskell-tng-util.el
+++ b/haskell-tng-util.el
@@ -115,9 +115,10 @@ flush the cache when the universal argument is provided."
       reset))
    sym
    nil
-   reset))
+   reset
+   'no-nil))
 
-(defun haskell-tng--util-cached-variable (work sym &optional no-work reset)
+(defun haskell-tng--util-cached-variable (work sym &optional no-work reset 
no-nil)
   "A variable cache over a function WORK.
 
 If the SYM reference contains a cache of a previous call, it is
@@ -127,7 +128,7 @@ Otherwise WORK is called with no parameters and saved to 
SYM.
 
 Errors are NOT cached.
 
-nil return values are cached.
+nil return values are cached unless NO-NIL is non-nil.
 
 NO-WORK skips WORK and only queries the cache.
 
@@ -137,7 +138,7 @@ RESET sets the variable to nil before doing anything."
   (when (not (symbol-value sym))
     (unless no-work
       (set sym (funcall work))
-      (unless (symbol-value sym)
+      (unless (or (symbol-value sym) no-nil)
         (set sym 'cached-nil))))
   (pcase (symbol-value sym)
     ('cached-nil nil)



reply via email to

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