Skip to content
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

When returning a SyntaxReference, also return the SyntaxSet that contains it #1776

Merged
merged 2 commits into from
Aug 8, 2021

Conversation

Enselic
Copy link
Collaborator

@Enselic Enselic commented Aug 3, 2021

Here comes what I think will be the most controversial change on the #951 journey, because it has the highest impact on the bat-as-a-library API. Let me know what you think about it.

To improve startup performance, we will later load smaller SyntaxSets instead of one giant one. However, the current API assumes only one SyntaxSet is ever used, and that that implicitly is the SyntaxSet from which returned SyntaxReferences comes.

This change changes the API to reflect that SyntaxSet and SyntaxReference are tightly coupled, and enables the use of several SyntaxSet.

I think it will make sense to add a helper method to reduce the boilerplate a bit, but I would like to get early feedback on the change itself before I do that.

…ains it

To improve startup performance, we will later load smaller `SyntaxSet`s instead
of one giant one. However, the current API assumes only one `SyntaxSet` is ever used,
and that that implicitly is the `SyntaxSet` from which returned `SyntaxReference`s
comes.

This change changes the API to reflect that `SyntaxSet` and `SyntaxReference`
are tightly coupled, and enables the use of several `SyntaxSet`.
@Enselic Enselic mentioned this pull request Aug 3, 2021
src/printer.rs Outdated Show resolved Hide resolved
Copy link
Owner

@sharkdp sharkdp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The proposed API changes looks good to me. The code as well.

@Enselic
Copy link
Collaborator Author

Enselic commented Aug 8, 2021

I fixed the destructuring comment. I also looked into ways to introduce a helper function, but couldn't come up with something I was happy with. So I'll go ahead and merge this now.

@Enselic Enselic merged commit d8b813c into sharkdp:master Aug 8, 2021
@Enselic Enselic deleted the syntax-reference-in-set branch August 8, 2021 06:26
Enselic added a commit to Enselic/bat that referenced this pull request Aug 8, 2021
…ains it (sharkdp#1776)

To improve startup performance, we will later load smaller `SyntaxSet`s instead
of one giant one. However, the current API assumes only one `SyntaxSet` is ever used,
and that that implicitly is the `SyntaxSet` from which returned `SyntaxReference`s
comes.

This change changes the API to reflect that `SyntaxSet` and `SyntaxReference`
are tightly coupled, and enables the use of several `SyntaxSet`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants