Skip to content
Discussion options

You must be logged in to vote

According to this answer it's advised to use in for readonly structs if it's more than the size of IntPtr.

As well as here https://devblogs.microsoft.com/premier-developer/the-in-modifier-and-the-readonly-structs-in-c/

If the size of a readonly struct is bigger than IntPtr.Size you should pass it as an in-parameter for performance reasons.

The statement and answers are incorrect. The latest version of the referenced documentation has removed the statement.
Passing the same unmodified struct in deep calls is not a common scenario. Memory<T> is usually constructed as a intermediate structure.

Moreover, passing by in has significant risk for atomicity. It's also unfriendly for struct dec…

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
5 replies
@unsafePtr
Comment options

@huoyaoyuan
Comment options

@tannergooding
Comment options

@unsafePtr
Comment options

@tannergooding
Comment options

Answer selected by tannergooding
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants