[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-29 ff66a5d324 2/2: (treesit--indent-rules-optimize): Optimize 'and
|
From: |
Dmitry Gutov |
|
Subject: |
emacs-29 ff66a5d324 2/2: (treesit--indent-rules-optimize): Optimize 'and' and 'or' matcher forms |
|
Date: |
Fri, 6 Jan 2023 19:45:42 -0500 (EST) |
branch: emacs-29
commit ff66a5d324b6cc88db27f48f351f2cb5baa08fa2
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>
(treesit--indent-rules-optimize): Optimize 'and' and 'or' matcher forms
* lisp/treesit.el (treesit--indent-rules-optimize):
Optimize 'and' and 'or' matcher forms. When 'and' has a 'query'
matcher inside (as is the case in ruby-ts--indent-rules, many
times over), this yields a significant performance boost.
---
lisp/treesit.el | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lisp/treesit.el b/lisp/treesit.el
index a85eb699ee..374c17c089 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -1546,6 +1546,10 @@ RULES."
(pcase func
(`(query ,qry)
(list 'query (treesit-query-compile lang qry)))
+ (`(and . ,fns)
+ (cons 'and (mapcar #'optimize-func fns)))
+ (`(or . ,fns)
+ (cons 'or (mapcar #'optimize-func fns)))
(_ func)))
;; Optimize a rule (MATCHER ANCHOR OFFSET).
(optimize-rule (rule)