(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.
This commit is contained in:
parent
f2ebe43362
commit
ff66a5d324
1 changed files with 4 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue