You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
NetTools.Bits static class is nice example of LINQ usage, but it's really slow.
Possible improvement ideas:
You can get like 33% less time spent on this when you use for cycles.
You can even optimize IPv6 comparison for IPv4ToIPv6 mapped addresses to reduce number of iterations from 16 to 4.
You can completely avoid some comparisons for IPv6 by checking IsIPv4MappedToIPv6
For the IPv4 address family you can use IPAddress.GetHashCode() which is 32-bit number as ip address. Casting hash code to uint would be still faster than the byte array comparison.
The text was updated successfully, but these errors were encountered:
NetTools.Bits static class is nice example of LINQ usage, but it's really slow.
Possible improvement ideas:
IsIPv4MappedToIPv6
IPAddress.GetHashCode()
which is 32-bit number as ip address. Casting hash code touint
would be still faster than the byte array comparison.The text was updated successfully, but these errors were encountered: