Why ReadOnlyMemory<T> is not passed by in modifier? #125485
-
|
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/
Does JIT has a speacial treatment for
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
|
Here is is the only two places where ReadOnlyMemory is passed by |
Beta Was this translation helpful? Give feedback.
-
The statement and answers are incorrect. The latest version of the referenced documentation has removed the statement. Moreover, passing by
No. They should NOT be passed by |
Beta Was this translation helpful? Give feedback.
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
inhas significant risk for atomicity. It's also unfriendly for struct dec…