-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Use more effective evaluation order in LanguagePrimitives.IsNullLike() #10781
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
Conversation
|
It was in #9794 (milestone 7.0-Preview2) as a breaking change without PowerShell Committee approve. So add the labels. |
|
@iSazonov the committee approved the change in the original issue (see #9561 (comment)) 🙂 |
|
My concern about order. |
|
Why is changing the order a breaking change? It doesn't change the behavior of this method, does it? |
|
Nope, it still checks the same things, just in a different order. 🙂 |
|
I see the logic is more simple than I thought. |
|
🎉 Handy links: |
…ullLike() (PowerShell#10781)" This reverts commit 25286eb.
PR Summary
Refactor
IsNullLike()to evaluate the most commonly-expectednull-like values first.New order of evaluation:
IsNull(value):value == nullvalue == AutomationNull.Valuevalue == DBNull.Valuevalue == AutomationNull.ValuePR Context
IsNullLike()is used in binders like-eq(e.g.,$null -eq $value)and it makes the most sense to evaluate in order of the most common null/null-like values first so that the code path short-circuits in the most common situations.PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.