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

Optimize field parsing #2102

Merged
merged 2 commits into from
Jan 30, 2024
Merged

Optimize field parsing #2102

merged 2 commits into from
Jan 30, 2024

Conversation

kyri-petrou
Copy link
Collaborator

Improves performance ~15-20% of the parser. The main optimization comes from avoiding parsing the field name twice in cases that it's not aliased (which is almost always)

index
)
P(Index ~ name ~ aliasOrName.? ~ arguments.? ~ directives.? ~ selectionSet.?).map {
case (index, alias, Some(name), args, dirs, sels) =>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the main optimization. If the 3rd parser succeeded (indicated by Some(_)), then it means we have an alias. This is much faster because the 3rd parser (aliasOrName) contains the : assertion at the start of the string rather than the end

@kyri-petrou kyri-petrou merged commit 8d4a177 into series/2.x Jan 30, 2024
10 checks passed
@kyri-petrou kyri-petrou deleted the optimize-parser branch January 30, 2024 10:28
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.

2 participants