summaryrefslogtreecommitdiff
path: root/fussy.lisp
diff options
context:
space:
mode:
authorcolin <colin@cicadas.surf>2023-05-26 09:01:36 -0700
committercolin <colin@cicadas.surf>2023-05-26 09:01:36 -0700
commitd919e5061c0f241884f4910c3481035b5a4f4b6a (patch)
tree15b499214a406b356a92ae50a30c74e3cb281eb3 /fussy.lisp
parent2b2b02c47455e90c90a833da4be7db32cab5a64d (diff)
caching closures for theme matching
Diffstat (limited to 'fussy.lisp')
-rw-r--r--fussy.lisp15
1 files changed, 10 insertions, 5 deletions
diff --git a/fussy.lisp b/fussy.lisp
index 4f20643..842902f 100644
--- a/fussy.lisp
+++ b/fussy.lisp
@@ -197,12 +197,17 @@ returns a list of those names."
(defun all-themes (&key sort-by)
(a:mappend #'themes-in-package (all-theme-packages sort-by)))
+(defvar *theme-matcher-cache* (make-hash-table :test #'equal))
+
(defun theme-mentions-anywhere (term)
- (lambda (theme)
- (or (search term theme)
- (with-slots (name keywords description authors maintainer) (theme-package theme)
- (or (search term (symbol-name name) :test #'char-equal)
- (search term description :test #'char-equal))))))
+ (or (gethash (string-downcase term) *theme-matcher-cache*)
+ (setf (gethash (string-downcase term) *theme-matcher-cache*)
+ (lambda (theme)
+ (or (search term theme)
+ (with-slots
+ (name keywords description authors maintainer) (theme-package theme)
+ (or (search term (symbol-name name) :test #'char-equal)
+ (search term description :test #'char-equal))))))))
(defun search-themes (terms &key sort-by)
(remove-if-not