Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 7087c6c

Browse files
Small optimization in BigInteger
While debugging something, I noticed that we run same BigInteger ctor repeatedly in a loop. This change runs the ctor once and caches the constant value to be used inside the loop.
1 parent a5fc7d8 commit 7087c6c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/System.Runtime.Numerics/src/System/Numerics/BigNumber.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,10 +432,11 @@ private unsafe static Boolean NumberToBigInteger(ref BigNumberBuffer number, ref
432432
Int32 i = number.scale;
433433
Int32 cur = 0;
434434

435+
BigInteger ten = 10;
435436
value = 0;
436437
while (--i >= 0)
437438
{
438-
value *= 10;
439+
value *= ten;
439440
if (number.digits[cur] != '\0')
440441
{
441442
value += (Int32)(number.digits[cur++] - '0');

0 commit comments

Comments
 (0)