-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Avoid byte[] allocation for IPAddressUtil.IsMulticast #68591
Conversation
Tagging subscribers to this area: @dotnet/ncl Issue DetailsPing.RawSocket his its own inline implementaion of this, maybe this
|
50afe26
to
7750536
Compare
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPAddressUtil.cs
Outdated
Show resolved
Hide resolved
7750536
to
2557f87
Compare
Ping.RawSocket his its own inline implementaion of this, maybe this should be consolidated somewhere? src/libraries/System.Net.Ping/src/System/Net/NetworkInformation/Ping.RawSocket.cs L101
2557f87
to
911b20e
Compare
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
byte firstByte = address.GetAddressBytes()[0]; | ||
#pragma warning disable CS0618 // using Obsolete Address API because it's the more efficient option in this case | ||
byte firstByte = (byte)address.Address; | ||
#pragma warning restore CS0618 | ||
return firstByte >= 224 && firstByte <= 239; |
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.
return firstByte >= 224 && firstByte <= 239; | |
return firstByte is >= 224 and <= 239; |
Once roslyn optimizes this (cf. dotnet/roslyn#60534), codegen improvement comes for free.
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.
I understand these are different constructs as far as Roslyn is concerned, but it's an unfortunate pit of failure if these otherwise identical expressions end up being optimized differently. I'd really like for us to not have to change all such range checks everywhere in order for the right things to happen.
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
Ping.RawSocket his its own inline implementaion of this, maybe this
should be consolidated somewhere?
src/libraries/System.Net.Ping/src/System/Net/NetworkInformation/Ping.RawSocket.cs
L101