-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Replace Unsafe.As with Unsafe.BitCast in SpanHelpers.Fill #116221
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
Conversation
|
Tagging subscribers to this area: @dotnet/area-system-memory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR replaces all uses of Unsafe.As with Unsafe.BitCast in SpanHelpers.Fill<T> to streamline vector creation and improve performance.
- Removed the temporary
tmpvariable and switched toUnsafe.BitCast<T, U>(value)for all supported element sizes. - Updated special-case branches for
floatanddoubleto useBitCast. - Simplified vector creation for 128-bit, 256-bit, and 512-bit cases by bit-casting
valuedirectly.
Comments suppressed due to low confidence (1)
src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs:36
- Consider adding unit tests for
Fill<T>covering each branch ofUnsafe.BitCastfor differentTsizes to ensure the fill behavior remains correct across all cases.
vector = new Vector<byte>(Unsafe.BitCast<T, byte>(value));
|
Context #111091 (comment) |
src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs
Outdated
Show resolved
Hide resolved
|
/ba-g timeouts, deadletter |
No description provided.