-
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
Minor cleanups for System.Runtime.Numerics #53984
Conversation
Tagging subscribers to this area: @tannergooding, @pgovind Issue DetailsMainly utilizing
|
@huoyaoyuan Just out of curiosity: I understand what Sorry for off topic question. I hope you guys won't mind too much. |
Yes. Roslyn will compose it. See sharplab Roslyn will first find an indexer accepts |
@@ -263,7 +263,7 @@ public BigInteger(ReadOnlySpan<byte> value, bool isUnsigned = false, bool isBigE | |||
bool isNegative; | |||
if (byteCount > 0) | |||
{ | |||
byte mostSignificantByte = isBigEndian ? value[0] : value[byteCount - 1]; | |||
byte mostSignificantByte = isBigEndian ? value[0] : value[^1]; |
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.
Does this impact codegen at all? I could imagine this being equivalent to value.Length - 1
, which might result in a secondary read from 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.
Given the size of this method, I think 1 length load should be OK
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.
Probably and for consistency, I'd just like to know if it is impactful at all, so we can more readily pin-point any changes in the perf issue triage.
src/libraries/System.Runtime.Numerics/src/System/Numerics/BigInteger.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Runtime.Numerics/src/System/Numerics/BigInteger.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Runtime.Numerics/src/System/Numerics/Complex.cs
Outdated
Show resolved
Hide resolved
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.
CC. @pgovind can you review as well?
Co-authored-by: Tanner Gooding <tagoo@outlook.com>
src/libraries/System.Runtime.Numerics/src/System/Numerics/NumericsHelpers.cs
Show resolved
Hide resolved
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.
LGTM!
Thanks for the cleanup here! |
As far as I can tell, this is ready to merge if the last leg turns green after re-running. @pgovind I've assigned to you for follow-up before the RC1 snap, and I've restarted the leg. |
This reverts commit 65439de.
Mainly utilizing
[^1]
and BitOperations.