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

Suboptimal code for e is null #13247

Closed
alrz opened this issue Aug 18, 2016 · 8 comments · Fixed by #18657
Closed

Suboptimal code for e is null #13247

alrz opened this issue Aug 18, 2016 · 8 comments · Fixed by #18657

Comments

@alrz
Copy link
Member

alrz commented Aug 18, 2016

Currently e is null translates to an object.Equals call on master. The question is that (1) does it meant to be a shorthand for explicit reference null check (object)e == null? If so, (2) shouldn't it just translate to a ceq?

@orthoxerox
Copy link
Contributor

What if e is a nullable value type? But I agree, the compiler can check this at compile time and emit better code for reference types.

@alrz alrz changed the title Question: null patterns Discussion: null patterns Aug 19, 2016
@gafter
Copy link
Member

gafter commented Aug 19, 2016

@alrz they should generate the same code

@gafter gafter changed the title Discussion: null patterns Suboptimal code for e is null Aug 19, 2016
@gafter gafter added this to the 2.0 (Preview 5) milestone Aug 19, 2016
@gafter gafter self-assigned this Aug 19, 2016
@alrz
Copy link
Member Author

alrz commented Aug 19, 2016

@gafter if so, I think this covers #8409 unless you have two non-constant expressions.

@jaredpar
Copy link
Member

Moving out for now as this doesn't meet the RTM bar.

@gafter
Copy link
Member

gafter commented Jan 12, 2017

Did you want to move #16129 out too?

@gafter
Copy link
Member

gafter commented Jan 12, 2017

Also #14252

@jaredpar
Copy link
Member

Yes and Yes. Thanks!

@jaredpar jaredpar removed this from the 15.1 milestone Mar 9, 2017
@gafter gafter assigned TyOverby and unassigned gafter Apr 18, 2017
@sharwell
Copy link
Member

💡 See #19803 for a very descriptive breakdown of the current and expected behavior for both Nullable<T> and reference types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants