-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Optimize shift operations for BigInteger #112632
Conversation
|
||
// Do an in-place one's complement. "Dangerous" because it causes | ||
// a mutation and needs to be used with care for immutable types. | ||
public static void DangerousMakeOnesComplement(Span<uint> d) |
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.
If it accepts a non-readonly span - what is dangerous with it? We typically name such things with "Inplace"
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.
I followed the existing DangerousMakeTwosComplement
. I have no strong preference for the naming convention, but if DangerousMakeOnesComplement
is to be renamed, then DangerousMakeTwosComplement
should be renamed as well.
runtime/src/libraries/System.Runtime.Numerics/src/System/Numerics/NumericsHelpers.cs
Line 100 in 8de6e01
public static void DangerousMakeTwosComplement(Span<uint> d) |
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.
np. It just that it's the code that converts an immutable data into mutable span is what actually dangerous 🙂
This is indeed behavioral change, could require design decision and breaking change announcement. |
2f4e87a
to
f0733dd
Compare
I noticed other compatibility-related problem, so I will esubmit new PR. |
I'd suggest to confirm the proposed behavioral change in the issue first. |
Fix #112564
This pull request includes the following changes:
RotateLeft
,RotateRight
and the unsigned right shift(>>>
).>>>
) of BigInteger behaves strangely #112564)Benchmark
benchmark code