-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Improved codegen in Guard APIs #3323
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
Improved codegen in Guard APIs #3323
Conversation
Thanks Sergio0694 for opening a Pull Request! The reviewers will test the PR and highlight if there is any conflict or changes required. If the PR is approved we will proceed to merge the pull request 🙌 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@michael-hawker Managed to fix my local branches, so there are no merge commits this time! 😄 |
I'm ok merging this. There is no behavioral change. Its only performance. |
Thanks @Sergio0694, @john-h-k, and @tannergooding for the discussion on this topic and the improvement to this new API! |
Hey @azchohfi and @michael-hawker - thank you for the super quick review and merge! 😄 |
Speed improvement for #3131 and #3167
PR Type
What kind of change does this PR introduce?
What is the current behavior?
The JIT compiler always assumes that forward branches are taken, unless it can see that the branch always throws. This doesn't happen in our throw methods, as we have a secondary
ThrowHelper.Throw...
method that actually creates the exceptions to throw in the correct format.What is the new behavior?
To work around this, all the
Guard
conditions have been inverted to guarantee that the forward branch considered taken is the one corresponding to the successful path for the check being done. This also improves code readability, as the conditions in eachGuard
API are no longer inverted.PR Checklist
Please check if your PR fulfills the following requirements:
Pull Request has been submitted to the documentation repository instructions. Link:Sample in sample app has been added / updated (for bug fixes / features)Icon has been created (if new sample) following the Thumbnail Style Guide and templates