diff options
author | colin <colin@cicadas.surf> | 2023-05-26 09:01:36 -0700 |
---|---|---|
committer | colin <colin@cicadas.surf> | 2023-05-26 09:01:36 -0700 |
commit | d919e5061c0f241884f4910c3481035b5a4f4b6a (patch) | |
tree | 15b499214a406b356a92ae50a30c74e3cb281eb3 /fussy.lisp | |
parent | 2b2b02c47455e90c90a833da4be7db32cab5a64d (diff) |
caching closures for theme matching
Diffstat (limited to 'fussy.lisp')
-rw-r--r-- | fussy.lisp | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -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 |