debbugs: Cache result of extract-bug-numbers.
authorRicardo Wurmus <rekado@elephly.net>
Sun, 10 May 2020 09:24:40 +0000 (11:24 +0200)
committerRicardo Wurmus <rekado@elephly.net>
Sun, 10 May 2020 09:24:40 +0000 (11:24 +0200)
mumi/debbugs.scm

index 086e89a63fe884935a82721b5e93bc0640f0c98e..4e0666ffabb4c5a8234a379e5e9017a888b6842c 100644 (file)
@@ -141,13 +141,20 @@ search the index of archived issues."
   "Open up a Debbugs index file and return the bug numbers for those
 lines that match one of PACKAGES.  If ARCHIVED? is #T search the index
 of archived issues."
-  (filter-index (lambda (line)
-                  (any (lambda (package)
-                         (string-prefix? package line))
-                       packages))
-                (lambda (line)
-                  (second (string-split line #\space)))
-                #:archived? archived?))
+  (define cache-key
+    (list 'extract-bug-numbers packages archived?))
+  (define cached (cached? cache-key))
+  (or cached
+      (let ((result
+             (filter-index (lambda (line)
+                             (any (lambda (package)
+                                    (string-prefix? package line))
+                                  packages))
+                           (lambda (line)
+                             (second (string-split line #\space)))
+                           #:archived? archived?)))
+        (cache! cache-key result)
+        result)))
 
 (define* (forgotten-bug-numbers packages #:key (seconds-ago (* 60 60 24 30)))
   "Return the numbers of issues that are open but haven't seen any