-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Potential optimization for is ""
#41779
Comments
That feels like a runtime optimziation to make. |
This is a special case of #33338 . |
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
cc @EgorBo |
Yes, if we could tune the inliner to be able to inline // Determines whether two Strings match.
public static bool Equals(string? a, string? b)
{
if (object.ReferenceEquals(a, b))
{
return true;
}
if (a is null || b is null || a.Length != b.Length)
{
return false;
}
return EqualsHelper(a, b);
} (the idea was to tell the inliner "if you see a However, I guess redundant |
Prototype with an intrinsic: EgorBo@7c4ef9f it optimizes |
Moving to future |
Based on the current master in sharplab:
https://sharplab.io/#v2:EYLgtghgzgLgpgJwD4AEDMACFAmDBhAWACgBvYjCrTYAexoBsMBZAChuACs4BjGDADwCU5SmSKUJWAOwCMASygYAREoDcIigF9imoA==
The following:
is compiled as:
It's a bit more performant if
return text == ""
istext.Length == 0
.That would be a special-casing for this, which I'm unsure if it's acceptable to the compiler team or not.
category:cq
theme:basic-cq
skill-level:intermediate
cost:small
The text was updated successfully, but these errors were encountered: