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 WriteEncodedStringAsync #216

Merged
merged 2 commits into from
Jan 26, 2022
Merged

Optimize WriteEncodedStringAsync #216

merged 2 commits into from
Jan 26, 2022

Conversation

sungam3r
Copy link
Member

Should be much faster in majority of cases.

@sungam3r sungam3r added this to the 8.0 milestone Jan 26, 2022
@sungam3r sungam3r self-assigned this Jan 26, 2022
await context.WriteAsync("\\\"").ConfigureAwait(false);
else
await context.WriteAsync(value.Slice(i, 1)/*code*/).ConfigureAwait(false); // TODO: no method for char
Copy link
Member Author

Choose a reason for hiding this comment

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

Hot path: await + one-symbol slicing

@Shane32 We should use the same approach for comments/block strings

Copy link
Member Author

Choose a reason for hiding this comment

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

So now in case of "normal" strings this loop does nothing just incrementing counter - single write is done at the end of method:
await context.WriteAsync(value.Slice(startIndexOfNotEncodedString, value.Span.Length - startIndexOfNotEncodedString)).ConfigureAwait(false);

@codecov-commenter
Copy link

Codecov Report

Merging #216 (7d72b67) into master (b41c261) will decrease coverage by 0.04%.
The diff coverage is 87.50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #216      +/-   ##
==========================================
- Coverage   98.96%   98.91%   -0.05%     
==========================================
  Files          84       84              
  Lines        4424     4439      +15     
  Branches      428      432       +4     
==========================================
+ Hits         4378     4391      +13     
- Misses         29       30       +1     
- Partials       17       18       +1     
Impacted Files Coverage Δ
src/GraphQLParser/Visitors/SDLPrinter.cs 97.88% <87.50%> (-0.23%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b41c261...7d72b67. Read the comment docs.

@github-actions github-actions bot added the test Pull request that adds new or changes existing tests label Jan 26, 2022
@sungam3r
Copy link
Member Author

I merge this and go on.

@sungam3r sungam3r merged commit c060519 into master Jan 26, 2022
@sungam3r sungam3r deleted the writes branch January 26, 2022 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance test Pull request that adds new or changes existing tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants