Skip to content

Commit 9156042

Browse files
committed
Fixing some naming conventions and removing dead code.
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
1 parent f8f8d41 commit 9156042

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

src/Common/src/CoreLib/System/Number.BigInteger.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ internal unsafe ref struct BigInteger
1515
{
1616
private const int MaxBlockCount = 35;
1717

18-
private static readonly uint[] Pow10UInt32Table = new uint[]
18+
private static readonly uint[] s_Pow10UInt32Table = new uint[]
1919
{
2020
1, // 10^0
2121
10, // 10^1
@@ -27,7 +27,7 @@ internal unsafe ref struct BigInteger
2727
10000000, // 10^7
2828
};
2929

30-
private static readonly int[] Pow10BigNumTableIndices = new int[]
30+
private static readonly int[] s_s_Pow10BigNumTableIndices = new int[]
3131
{
3232
0, // 10^8
3333
2, // 10^16
@@ -37,7 +37,7 @@ internal unsafe ref struct BigInteger
3737
33, // 10^256
3838
};
3939

40-
private static readonly uint[] Pow10BigNumTable = new uint[]
40+
private static readonly uint[] s_Pow10BigNumTable = new uint[]
4141
{
4242
// 10^8
4343
1, // _length
@@ -123,7 +123,7 @@ internal unsafe ref struct BigInteger
123123
0x00000000,
124124
};
125125

126-
private static readonly uint[] MultiplyDeBruijnBitPosition = new uint[]
126+
private static readonly uint[] s_MultiplyDeBruijnBitPosition = new uint[]
127127
{
128128
0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30,
129129
8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31
@@ -161,7 +161,7 @@ public static uint BitScanReverse(uint mask)
161161
mask |= (mask >> 16);
162162

163163
uint index = (mask * 0x07C4ACDD) >> 27;
164-
return MultiplyDeBruijnBitPosition[(int)(index)];
164+
return s_MultiplyDeBruijnBitPosition[(int)(index)];
165165
}
166166

167167
public static int Compare(ref BigInteger lhs, ref BigInteger rhs)
@@ -367,7 +367,7 @@ public static void Multiply(ref BigInteger lhs, ref BigInteger rhs, ref BigInteg
367367
Debug.Assert(unchecked((uint)(maxResultLength)) <= MaxBlockCount);
368368

369369
// Zero out result internal blocks.
370-
Buffer.ZeroMemory((byte*)(result._blocks.GetPointer()), (MaxBlockCount * sizeof(uint)));
370+
Buffer.ZeroMemory((byte*)(result._blocks.GetPointer()), (maxResultLength * sizeof(uint)));
371371

372372
int smallIndex = 0;
373373
int resultStartIndex = 0;
@@ -412,33 +412,33 @@ public static void Multiply(ref BigInteger lhs, ref BigInteger rhs, ref BigInteg
412412

413413
public static void Pow10(uint exponent, ref BigInteger result)
414414
{
415-
// We leverage two arrays - Pow10UInt32Table and Pow10BigNumTable to speed up the Pow10 calculation.
415+
// We leverage two arrays - s_Pow10UInt32Table and s_Pow10BigNumTable to speed up the Pow10 calculation.
416416
//
417-
// Pow10UInt32Table stores the results of 10^0 to 10^7.
418-
// Pow10BigNumTable stores the results of 10^8, 10^16, 10^32, 10^64, 10^128 and 10^256.
417+
// s_Pow10UInt32Table stores the results of 10^0 to 10^7.
418+
// s_Pow10BigNumTable stores the results of 10^8, 10^16, 10^32, 10^64, 10^128 and 10^256.
419419
//
420420
// For example, let's say exp = 0b111111. We can split the exp to two parts, one is small exp,
421421
// which 10^smallExp can be represented as uint, another part is 10^bigExp, which must be represented as BigNum.
422422
// So the result should be 10^smallExp * 10^bigExp.
423423
//
424-
// Calculating 10^smallExp is simple, we just lookup the 10^smallExp from Pow10UInt32Table.
424+
// Calculating 10^smallExp is simple, we just lookup the 10^smallExp from s_Pow10UInt32Table.
425425
// But here's a bad news: although uint can represent 10^9, exp 9's binary representation is 1001.
426426
// That means 10^(1011), 10^(1101), 10^(1111) all cannot be stored as uint, we cannot easily say something like:
427-
// "Any bits <= 3 is small exp, any bits > 3 is big exp". So instead of involving 10^8, 10^9 to Pow10UInt32Table,
428-
// consider 10^8 and 10^9 as a bigNum, so they fall into Pow10BigNumTable. Now we can have a simple rule:
427+
// "Any bits <= 3 is small exp, any bits > 3 is big exp". So instead of involving 10^8, 10^9 to s_Pow10UInt32Table,
428+
// consider 10^8 and 10^9 as a bigNum, so they fall into s_Pow10BigNumTable. Now we can have a simple rule:
429429
// "Any bits <= 3 is small exp, any bits > 3 is big exp".
430430
//
431431
// For 0b111111, we first calculate 10^(smallExp), which is 10^(7), now we can shift right 3 bits, prepare to calculate the bigExp part,
432432
// the exp now becomes 0b000111.
433433
//
434-
// Apparently the lowest bit of bigExp should represent 10^8 because we have already shifted 3 bits for smallExp, so Pow10BigNumTable[0] = 10^8.
434+
// Apparently the lowest bit of bigExp should represent 10^8 because we have already shifted 3 bits for smallExp, so s_Pow10BigNumTable[0] = 10^8.
435435
// Now let's shift exp right 1 bit, the lowest bit should represent 10^(8 * 2) = 10^16, and so on...
436436
//
437-
// That's why we just need the values of Pow10BigNumTable be power of 2.
437+
// That's why we just need the values of s_Pow10BigNumTable be power of 2.
438438
//
439439
// More details of this implementation can be found at: https://github.com/dotnet/coreclr/pull/12894#discussion_r128890596
440440

441-
BigInteger temp1 = new BigInteger(Pow10UInt32Table[exponent & 0x7]);
441+
BigInteger temp1 = new BigInteger(s_Pow10UInt32Table[exponent & 0x7]);
442442
ref BigInteger lhs = ref temp1;
443443

444444
BigInteger temp2 = new BigInteger(0);
@@ -453,7 +453,7 @@ public static void Pow10(uint exponent, ref BigInteger result)
453453
if ((exponent & 1) != 0)
454454
{
455455
// Multiply into the next temporary
456-
ref BigInteger rhs = ref *(BigInteger*)(Unsafe.AsPointer(ref Pow10BigNumTable[Pow10BigNumTableIndices[index]]));
456+
ref BigInteger rhs = ref *(BigInteger*)(Unsafe.AsPointer(ref s_Pow10BigNumTable[s_s_Pow10BigNumTableIndices[index]]));
457457
Multiply(ref lhs, ref rhs, ref product);
458458

459459
// Swap to the next temporary

src/Common/src/CoreLib/System/Number.Formatting.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2290,7 +2290,7 @@ private static unsafe void DoubleToNumber(double value, int precision, ref Numbe
22902290
{
22912291
number.precision = precision;
22922292

2293-
if (double.GetExponent(value) == 0x7FF)
2293+
if (!double.IsFinite(value))
22942294
{
22952295
number.scale = double.IsNaN(value) ? ScaleNAN : ScaleINF;
22962296
number.sign = double.IsNegative(value);

src/Common/src/CoreLib/System/Number.Grisu3.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ internal static unsafe class Grisu3
2424
private const uint Ten8 = 100000000;
2525
private const uint Ten9 = 1000000000;
2626

27-
private static readonly short[] CachedPowerBinaryExponents = new short[]
27+
private static readonly short[] s_CachedPowerBinaryExponents = new short[]
2828
{
2929
-1220,
3030
-1193,
@@ -115,7 +115,7 @@ internal static unsafe class Grisu3
115115
1066,
116116
};
117117

118-
private static readonly short[] CachedPowerDecimalExponents = new short[]
118+
private static readonly short[] s_CachedPowerDecimalExponents = new short[]
119119
{
120120
PowerMinDecimalExponent,
121121
-340,
@@ -206,7 +206,7 @@ internal static unsafe class Grisu3
206206
PowerMaxDecimalExponent,
207207
};
208208

209-
private static readonly uint[] CachedPowerOfTen = new uint[]
209+
private static readonly uint[] s_CachedPowerOfTen = new uint[]
210210
{
211211
1, // 10^0
212212
10, // 10^1
@@ -220,7 +220,7 @@ internal static unsafe class Grisu3
220220
1000000000, // 10^9
221221
};
222222

223-
private static readonly ulong[] CachedPowerSignificands = new ulong[]
223+
private static readonly ulong[] s_CachedPowerSignificands = new ulong[]
224224
{
225225
0xFA8FD5A0081C0288,
226226
0xBAAEE17FA23EBF76,
@@ -545,8 +545,8 @@ static void BiggestPowerTenLessThanOrEqualTo(uint number, int bits, out uint pow
545545
private static void CachedPower(int k, out DiyFp cmk, out int decimalExponent)
546546
{
547547
int index = ((PowerOffset + k - 1) / PowerDecimalExponentDistance) + 1;
548-
cmk = new DiyFp(CachedPowerSignificands[index], CachedPowerBinaryExponents[index]);
549-
decimalExponent = CachedPowerDecimalExponents[index];
548+
cmk = new DiyFp(s_CachedPowerSignificands[index], s_CachedPowerBinaryExponents[index]);
549+
decimalExponent = s_CachedPowerDecimalExponents[index];
550550
}
551551

552552
private static bool DigitGen(ref DiyFp mp, int precision, char* digits, out int length, out int k)
@@ -582,7 +582,7 @@ private static bool DigitGen(ref DiyFp mp, int precision, char* digits, out int
582582
// - When requested digit count >= 11, p1 is not be able to exhaust the count as 10^(11 - 1) > uint.MaxValue >= p1.
583583
// - When p1 < 10^(count - 1), p1 is not be able to exhaust the count.
584584
// - Otherwise, p1 may have chance to exhaust the count.
585-
if ((p2 == 0) && ((precision >= 11) || (p1 < CachedPowerOfTen[precision - 1])))
585+
if ((p2 == 0) && ((precision >= 11) || (p1 < s_CachedPowerOfTen[precision - 1])))
586586
{
587587
length = 0;
588588
k = 0;

0 commit comments

Comments
 (0)