aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Gutov2023-01-07 02:44:07 +0200
committerDmitry Gutov2023-01-07 02:44:07 +0200
commitff66a5d324b6cc88db27f48f351f2cb5baa08fa2 (patch)
tree9b95bfd34f00ec944022edd7ca6f8616d468276a
parentf2ebe43362cab1b8d88674dad60b1ed3c822bb54 (diff)
downloademacs-ff66a5d324b6cc88db27f48f351f2cb5baa08fa2.tar.gz
emacs-ff66a5d324b6cc88db27f48f351f2cb5baa08fa2.zip
(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.
-rw-r--r--lisp/treesit.el4
1 files changed, 4 insertions, 0 deletions
diff --git a/lisp/treesit.el b/lisp/treesit.el
index a85eb699ee1..374c17c0894 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -1546,6 +1546,10 @@ RULES."
1546 (pcase func 1546 (pcase func
1547 (`(query ,qry) 1547 (`(query ,qry)
1548 (list 'query (treesit-query-compile lang qry))) 1548 (list 'query (treesit-query-compile lang qry)))
1549 (`(and . ,fns)
1550 (cons 'and (mapcar #'optimize-func fns)))
1551 (`(or . ,fns)
1552 (cons 'or (mapcar #'optimize-func fns)))
1549 (_ func))) 1553 (_ func)))
1550 ;; Optimize a rule (MATCHER ANCHOR OFFSET). 1554 ;; Optimize a rule (MATCHER ANCHOR OFFSET).
1551 (optimize-rule (rule) 1555 (optimize-rule (rule)