-
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
Improve IPAddress to/from bytes perf #75872
Conversation
Also cleaned up some unnecessary `!`s with `MemberNotNullWhen`.
Tagging subscribers to this area: @dotnet/ncl Issue DetailsAlso cleaned up some unnecessary private IPAddress _addr1 = IPAddress.Parse("1.2.3.4").MapToIPv6();
private IPAddress _addr2 = IPAddress.Parse("2600:141b:13:781::356e");
private IPAddress _addr3 = IPAddress.Parse("2600:141b:13:781::356e");
private byte[] _ipv6Bytes = IPAddress.Parse("2600:141b:13:781::356e").GetAddressBytes();
[Benchmark] public bool IsIPv4MappedToIPv6_True() => _addr1.IsIPv4MappedToIPv6;
[Benchmark] public bool IsIPv4MappedToIPv6_False() => _addr2.IsIPv4MappedToIPv6;
[Benchmark] public IPAddress NewIPv6() => new IPAddress(_ipv6Bytes, 0);
[Benchmark] public bool WriteBytes() => _addr3.TryWriteBytes(_ipv6Bytes, out _);
|
src/libraries/System.Net.Primitives/src/System/Net/IPAddress.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Primitives/src/System/Net/IPAddress.cs
Outdated
Show resolved
Hide resolved
And also simplify fallback.
/azp run runtime-extra-platforms |
Azure Pipelines successfully started running 1 pipeline(s). |
src/libraries/System.Net.Primitives/src/System/Net/IPAddress.cs
Outdated
Show resolved
Hide resolved
Improvements dotnet/perf-autofiling-issues#8818 (comment) (and other improvements throughout the issue. We are filing all improvements and regressions from a single commit range in a single issue now, hence why this is so long and contains unrelated regressions) |
Also cleaned up some unnecessary
!
s withMemberNotNullWhen
.