-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Use span copy in BigInteger.TryGetBytes when applicable #115445
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
When the value is positive (we don't need to do two's complement conversion) and on a little endian machine, we can copy the bytes out from the underlying uint[] storage.
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.
The whole method is not as efficient as it can. There are multiple problems, for example BitConverter.IsLittleEndian
is an intrinsic so it shouldn't be passed as a parameter.
A bottom-up rewrite is better.
Tagging subscribers to this area: @dotnet/area-system-numerics |
@huoyaoyuan |
Yes, you are right, I misread it as the same of |
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.
Thanks.
When the value is positive (we don't need to do two's complement conversion) and on a little endian machine, we can copy the bytes out from the underlying uint[] storage.