Spanize interop in System.Net.NetworkInformation by jkotas · Pull Request #35098 · dotnet/runtime (original) (raw)
Which bits make it faster and which safer? It looks like it's adding unsafe modifiers (for the fixed) which makes is counter intuitive to be safer from a casual perspective.
The faster part is e.g. not using array marshaling and PtrToStructure, and using sizeof instead of Marshal.SizeOf.
The safer part is using span slicing instead of math on pointers, with the spans being bounds checked.