From d919e5061c0f241884f4910c3481035b5a4f4b6a Mon Sep 17 00:00:00 2001 From: colin Date: Fri, 26 May 2023 09:01:36 -0700 Subject: caching closures for theme matching --- fussy.lisp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'fussy.lisp') 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 -- cgit v1.2.3