-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Use Unsafe.BitCast
for generic span casting
#109136
base: main
Are you sure you want to change the base?
Conversation
cc: @fanyang-mono |
d55b468
to
f488388
Compare
@MihuBot -mono |
The bot doesn't support mono |
Tagging subscribers to this area: @dotnet/area-meta |
One of our main focuses currently is to reduce unsafe code in the repo (ideally, with zero performance impact, but we might tolerate small regressions in favor of memory safety), see #94941. This change seems to replace one unsafe pattern with another. Or in case of |
|
All of our uses of "unsafe" constructs are safe; otherwise they'd be bugs to be fixed. The desire to reduce the reliance on such constructs is to reduce the possibility that we might make a mistake, allowing normal runtime protections to be in effect. |
Alternative to dotnet#109136
I've tried just making MemoryMarshal use BitCast internally but that gives 0 diffs anyway so not sure either of the changes makes sense. |
Something similar has already been tried: #100750 |
Related:
MemoryMarshal.Cast
for same type #100750