Skip to content

Commit

Permalink
Optimize threshold of BigInteger.Parse (#97101)
Browse files Browse the repository at this point in the history
* Update threshold of BigInteger.Parse

* Set threshold to 1233

* Add comment
  • Loading branch information
kzrnm authored Jan 29, 2024
1 parent 0fce832 commit 678ae31
Showing 1 changed file with 5 additions and 1 deletion.
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

0 comments on commit 678ae31

Please sign in to comment.