Skip to content
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 threshold of BigInteger.Parse #97101

Merged
merged 3 commits into from
Jan 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -662,13 +662,17 @@ internal static ParsingStatus TryParseBigIntegerBinaryNumberStyle(ReadOnlySpan<c
// algorithm with a running time of O(N^2). And if it is greater than the threshold, use
// a divide-and-conquer algorithm with a running time of O(NlogN).
//
// `1233`, which is approx the upper bound of most RSA key lengths, covers the majority
// of most common inputs and allows for the less naive algorithm to be used for
// large/uncommon inputs.
//
#if DEBUG
// Mutable for unit testing...
internal static
#else
internal const
#endif
int s_naiveThreshold = 20000;
int s_naiveThreshold = 1233;
private static ParsingStatus NumberToBigInteger(ref NumberBuffer number, out BigInteger result)
{
int currentBufferSize = 0;
Expand Down
Loading