mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-12-14 09:39:42 +00:00
Cache results of `css--property-values'
* lisp/textmodes/css-mode.el (css--property-values): Cache computed values. * test/lisp/textmodes/css-mode-tests.el (css-test-property-value-cache): New regression test for the above.
This commit is contained in:
parent
5cb7620027
commit
8e2e252932
@ -792,13 +792,15 @@ the symbol VALUE-CLASS."
|
||||
Completion candidates are looked up in `css-property-alist' by
|
||||
the string PROPERTY."
|
||||
(or (gethash property css--property-value-cache)
|
||||
(seq-mapcat
|
||||
(lambda (value)
|
||||
(if (stringp value)
|
||||
(list value)
|
||||
(or (css--value-class-lookup value)
|
||||
(css--property-values (symbol-name value)))))
|
||||
(cdr (assoc property css-property-alist)))))
|
||||
(let ((values
|
||||
(seq-mapcat
|
||||
(lambda (value)
|
||||
(if (stringp value)
|
||||
(list value)
|
||||
(or (css--value-class-lookup value)
|
||||
(css--property-values (symbol-name value)))))
|
||||
(cdr (assoc property css-property-alist)))))
|
||||
(puthash property values css--property-value-cache))))
|
||||
|
||||
(defun css--complete-property-value ()
|
||||
"Complete property value at point."
|
||||
|
@ -57,6 +57,13 @@
|
||||
;; because it refers to the value class of the same name.
|
||||
(should (= (length (css--property-values "color")) 18)))
|
||||
|
||||
(ert-deftest css-test-property-value-cache ()
|
||||
"Test that `css--property-value-cache' is in use."
|
||||
(should-not (gethash "word-wrap" css--property-value-cache))
|
||||
(let ((word-wrap-values (css--property-values "word-wrap")))
|
||||
(should (equal (gethash "word-wrap" css--property-value-cache)
|
||||
word-wrap-values))))
|
||||
|
||||
(ert-deftest css-test-value-class-lookup ()
|
||||
(should
|
||||
(equal (sort (css--value-class-lookup 'position) #'string-lessp)
|
||||
|
Loading…
Reference in New Issue
Block a user