Skip to content
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

Spanize interop in System.Net.NetworkInformation #35098

Merged
merged 1 commit into from
Apr 18, 2020

Conversation

jkotas
Copy link
Member

@jkotas jkotas commented Apr 17, 2020

Faster and safer

@ghost
Copy link

ghost commented Apr 17, 2020

Tagging subscribers to this area: @dotnet/ncl
Notify danmosemsft if you want to be subscribed.

@jkotas
Copy link
Member Author

jkotas commented Apr 17, 2020

Depends on #35078

@jkotas jkotas requested a review from wfurt April 17, 2020 04:46
Copy link
Member

@wfurt wfurt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Wraith2
Copy link
Contributor

Wraith2 commented Apr 17, 2020

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.

Copy link
Member

@stephentoub stephentoub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

@stephentoub
Copy link
Member

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.

@davidsh davidsh added this to the 5.0 milestone Apr 17, 2020
@jkotas
Copy link
Member Author

jkotas commented Apr 17, 2020

unsafe modifiers (for the fixed) which makes is counter intuitive to be safe

unsafe modifier is required for unsafe C# language constructs, but not for unsafe APIs. It makes a poor indicator for whether the code is actually unsafe. #31354 should make it better.

@jkotas jkotas merged commit 8b41d4c into dotnet:master Apr 18, 2020
@jkotas jkotas deleted the better-interop branch April 23, 2020 19:39
@ghost ghost locked as resolved and limited conversation to collaborators Dec 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants