-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Split the bindings for TSQuery
and TSQueryCursor
into multiple classes
#66
Comments
Merging them is required to support predicates. |
I also think that splitting the current
This is similar to how Java's Regex classes in the Though I am not sure if that would be fully compatible with @Emmeral's use case.
This is probably not only a performance advantage, but also a correctness one. Users can create the
Does that problem also apply when not strictly splitting into Footnotes
|
This is not true if you expose the predicates of the query with a getter (either public or package private) and have a |
I did a quick implementation of the proposed ideas: master...Emmeral:java-tree-sitter:SplitQueryAndQueryCursor Nothing production ready, but maybe helpful to understand the idea better. |
Currently the
Query
class maintains the state of both aTSQuery
andTSQueryCursor
(c.f. here). It has methods that work with both of them (i.e. here).Splitting it into two separate classes has the following advantages:
Arena.ofShared()
but the tree-sitter documentation mentions that aTSQueryCursor
shall only be accessed by a single thread. Allocating the cursor by an arena that can be accessed by multiple threads makes it more error prone.TSQueryCursor
methods (e.g.ts_query_cursor_next_match
). They must not use theQuery::findMatches
logic if they do not desire it.QueryCursor
class instead of theQuery
class. This way and application can keep the sameQuery
instance for its entire runtime without leaking memory.However the change would imply breaking API changes:
Query
class that currently set properties of aTSQueryCursor
would need to be moved to the newQueryCursor
classQuery::findMatches
methods would need anQueryCursor
as an additional argument.The text was updated successfully, but these errors were encountered: