-
Notifications
You must be signed in to change notification settings - Fork 64
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
[T(Index) Is Nothing] is [CObj(T(Index)) Is Nothing] instead [T(Index) Is Default]. #605
Comments
There is nothing to be fixed. What you really want is a proper "Is Default" test - something that can tell us if a reference or value-type expression is just all of its bits set to 0. That's what "default" means, in the .NET sense. All 0's is a null for a reference type or a zero for (typical) numeric types or what the default of any given |
@rskar-git , How would you check is value of generic type is default in VB.Net ? Compiler programmer is |
For an unconstrained T, where you want the position of a null for references or default for value-types or default of a value-type boxed as an Object, then maybe:
|
With so many if and type access info I think those cut corner won't make it better then just use |
Nicer code:
|
Why not Object.Equals ?
Simple answer is super cut corner for performance as you see in IL code below.
Instead call
Object.Equals
it use0
akanull pointer
compare result so whenbrtrue
which is branch on true and true in this case is anything except0
.How to fixed it ?
Just reverse back to use
Object.Equals
.Or double down it, cut more corner.
The text was updated successfully, but these errors were encountered: