]> git.eshelyaron.com Git - emacs.git/commitdiff
ruby-ts-mode: Claw back half of the performance drop from last change
authorDmitry Gutov <dgutov@yandex.ru>
Fri, 20 Jan 2023 03:35:12 +0000 (05:35 +0200)
committerDmitry Gutov <dgutov@yandex.ru>
Fri, 20 Jan 2023 03:35:12 +0000 (05:35 +0200)
* lisp/progmodes/ruby-ts-mode.el (ruby-ts--builtin-method-p):
New function.
(ruby-ts--font-lock-settings): Use it instead of :match.

lisp/progmodes/ruby-ts-mode.el

index 58da5ef9c69f64abaee599b5f0cdf1a7a7589707..2105aaaecab62961ee615a5e2e86212fb07b349c 100644 (file)
@@ -208,6 +208,9 @@ values of OVERRIDE"
     (treesit-fontify-with-override (max plus-1 start) (min node-end end)
                                    font-lock-comment-face override)))
 
+(defun ruby-ts--builtin-method-p (node)
+  (string-match-p ruby-ts--builtin-methods (treesit-node-text node t)))
+
 (defun ruby-ts--font-lock-settings (language)
   "Tree-sitter font-lock settings for Ruby."
   (treesit-font-lock-rules
@@ -336,8 +339,7 @@ values of OVERRIDE"
    :language language
    :feature 'builtin-function
    `((((identifier) @font-lock-builtin-face)
-      (:match ,ruby-ts--builtin-methods
-       @font-lock-builtin-face)))
+      (:pred ruby-ts--builtin-method-p @font-lock-builtin-face)))
 
    ;; Yuan recommends also putting method definitions into the
    ;; 'function' category (thus keeping it in both).  I've opted to