UserNobody14 / tree-sitter-dart

Attempt to make a tree-sitter grammar for dart
MIT License
62 stars 40 forks source link

performance improvement #47

Closed ktakayama closed 1 year ago

ktakayama commented 1 year ago

This PR is just a workaround fix for #46. all test passed

Performance

Test source

$ cat queries/good.scm
(if_statement)
$ cat queries/bad.scm
(if_statement (block))
$ cat empty.dart # empty file

before changes

$ time tree-sitter query queries/good.scm empty.dart
tree-sitter query queries/good.scm empty.dart  0.01s user 0.00s system 61% cpu 0.021 total

$ time tree-sitter query queries/bad.scm empty.dart
tree-sitter query queries/bad.scm empty.dart  1.23s user 0.01s system 99% cpu 1.245 total

after changes

$ time tree-sitter query queries/good.scm empty.dart
tree-sitter query queries/good.scm empty.dart  0.01s user 0.00s system 74% cpu 0.017 total

$ time tree-sitter query queries/bad.scm empty.dart
tree-sitter query queries/bad.scm empty.dart  0.14s user 0.00s system 97% cpu 0.148 total
TimWhiting commented 1 year ago

Thanks, I ended up commenting it out rather than removing it completely, we need to figure out a way to reinsert it eventually since it allows you to control precedence of patterns. As there is very little such code out there currently, I'll ignore it for now. It would be great though if we could get a failing test added so that we can work on eventually reinserting this piece of the grammar.

Anyways, thanks for the PR. I'll add your name to the contributors in package.json, even though I didn't merge this PR. If you want to contribute a failing test, that would be much appreciated.

TimWhiting commented 1 year ago

@theHamsta

This change is incorporated, and you can update nvim to the latest commit.

ktakayama commented 1 year ago

Thanks for the great job!