summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStephen Toub <stoub@microsoft.com>2017-11-15 18:18:20 -0500
committerStephen Toub <stoub@microsoft.com>2017-11-18 17:59:07 -0500
commit523ee2d35552f6ab6ff9228da2a9d7cfe51e4b57 (patch)
treeab7d91b37884b6a879d954f08e4133b2b85589a5 /src
parent7f0eb6109c8572e15c5a263c864f53fb2442baf3 (diff)
downloadcoreclr-523ee2d35552f6ab6ff9228da2a9d7cfe51e4b57.tar.gz
coreclr-523ee2d35552f6ab6ff9228da2a9d7cfe51e4b57.tar.bz2
coreclr-523ee2d35552f6ab6ff9228da2a9d7cfe51e4b57.zip
Remove now dead code from managed parsing/formatting.
- Remove dead "bigNumber" code. - Remove custom wcslen function. Use String's. - Delete dead fcalls from runtime. FormatInt32, FormatUInt32, FormatInt64, and FormatUInt64 are no longer needed. Delete them and many of the helpers used only by them.
Diffstat (limited to 'src')
-rw-r--r--src/classlibnative/bcltype/number.cpp558
-rw-r--r--src/classlibnative/bcltype/number.h4
-rw-r--r--src/mscorlib/shared/System/Number.Formatting.cs60
-rw-r--r--src/mscorlib/shared/System/Number.Parsing.cs25
-rw-r--r--src/vm/ecalllist.h4
5 files changed, 13 insertions, 638 deletions
diff --git a/src/classlibnative/bcltype/number.cpp b/src/classlibnative/bcltype/number.cpp
index c45260d05b..e399c82f63 100644
--- a/src/classlibnative/bcltype/number.cpp
+++ b/src/classlibnative/bcltype/number.cpp
@@ -113,24 +113,6 @@ L2: dec ecx
}
}
-unsigned int Int64DivMod1E9(unsigned __int64* value)
-{
- LIMITED_METHOD_CONTRACT
-
- _asm {
- mov ebx,value
- mov ecx,1000000000
- xor edx,edx
- mov eax,[ebx+4]
- div ecx
- mov [ebx+4],eax
- mov eax,[ebx]
- div ecx
- mov [ebx],eax
- mov eax,edx
- }
-}
-
#pragma warning(default:4035)
#else // _TARGET_X86_ && !FEATURE_PAL
@@ -863,20 +845,6 @@ wchar_t* COMNumber::Int32ToDecChars(__in wchar_t* p, unsigned int value, int dig
}
return p;
}
-
-unsigned int Int64DivMod1E9(unsigned __int64* value)
-{
- LIMITED_METHOD_CONTRACT
- _ASSERTE(value != NULL);
-
- unsigned int rem = (unsigned int)(*value % 1000000000);
- *value /= 1000000000;
- return rem;
-}
-
-
-
-
#endif // _TARGET_X86_ && !FEATURE_PAL
#if defined(_MSC_VER) && defined(_TARGET_X86_)
@@ -906,284 +874,6 @@ inline wchar* GetDigitsBuffer(NUMBER* number)
#pragma optimize("", on) // Go back to command line default optimizations
#endif
-LPCWSTR MatchChars(LPCWSTR p, LPCWSTR str)
-{
- LIMITED_METHOD_CONTRACT
- _ASSERTE(p != NULL && str != NULL);
-
- if (!*str) return 0;
- for (; *str; p++, str++)
- {
- if (*p != *str) //We only hurt the failure case
- {
- if ((*str == 0xA0) && (*p == 0x20)) // This fix is for French or Kazakh cultures. Since a user cannot type 0xA0 as a
- // space character we use 0x20 space character instead to mean the same.
- continue;
- return 0;
- }
- }
- return p;
-}
-
-wchar* Int32ToHexChars(__in wchar* p, unsigned int value, int hexBase, int digits)
-{
- LIMITED_METHOD_CONTRACT
- _ASSERTE(p != NULL);
-
- while (--digits >= 0 || value != 0) {
- unsigned char digit = static_cast<unsigned char>(value & 0xF);
- *--p = static_cast<wchar>(digit + (digit < 10? '0': hexBase));
- value >>= 4;
- }
- return p;
-}
-
-STRINGREF Int32ToDecStr(int value, int digits, STRINGREF sNegative)
-{
- CONTRACTL {
- THROWS;
- INJECT_FAULT(COMPlusThrowOM());
- GC_TRIGGERS;
- MODE_COOPERATIVE;
- } CONTRACTL_END;
-
- CQuickBytes buf;
-
- if (digits < 1) digits = 1;
-
- UINT maxDigitsLength = (digits > 15) ? digits : 15; // Since an int32 can have maximum of 10 chars as a String
- UINT bufferLength = (maxDigitsLength > 100) ? maxDigitsLength : 100;
- int negLength = 0;
- wchar* src = NULL;
-
- if (value < 0) {
- _ASSERTE(sNegative != NULL);
- src = sNegative->GetBuffer();
- _ASSERTE(src != NULL);
- negLength = sNegative->GetStringLength();
- if ((UINT) negLength > bufferLength - maxDigitsLength) {
- bufferLength = (UINT) negLength + maxDigitsLength;
- }
- }
-
- wchar *buffer = (wchar*)buf.AllocThrows(bufferLength * sizeof(WCHAR));
- wchar* p = COMNumber::Int32ToDecChars(buffer + bufferLength, value >= 0? value: -value, digits);
- _ASSERTE(p != NULL);
- if (value < 0) {
- for (int i =negLength - 1; i >= 0; i--)
- {
- *(--p) = *(src+i);
- }
- }
-
- _ASSERTE(buffer + bufferLength - p >=0 && buffer <= p);
- return StringObject::NewString(p, (int)(buffer + bufferLength - p));
-}
-
-STRINGREF UInt32ToDecStr(unsigned int value, int digits)
-{
- WRAPPER_NO_CONTRACT
-
- wchar buffer[100];
- if (digits < 1) digits = 1;
- wchar* p = COMNumber::Int32ToDecChars(buffer + 100, value, digits);
- _ASSERTE(p != NULL && p >= buffer && p < (buffer + 100));
- return StringObject::NewString(p, (int) (buffer + 100 - p));
-}
-
-STRINGREF Int32ToHexStr(unsigned int value, int hexBase, int digits)
-{
- WRAPPER_NO_CONTRACT
-
- wchar buffer[100];
- if (digits < 1) digits = 1;
- wchar* p = Int32ToHexChars(buffer + 100, value, hexBase, digits);
- return StringObject::NewString(p, (int) (buffer + 100 - p));
-}
-
-void Int32ToNumber(int value, NUMBER* number)
-{
- WRAPPER_NO_CONTRACT
- _ASSERTE(number != NULL);
-
- wchar buffer[INT32_PRECISION+1];
- number->precision = INT32_PRECISION;
- if (value >= 0) {
- number->sign = 0;
- }
- else {
- number->sign = 1;
- value = -value;
- }
- wchar* p = COMNumber::Int32ToDecChars(buffer + INT32_PRECISION, value, 0);
- _ASSERTE(p != NULL);
- int i = (int) (buffer + INT32_PRECISION - p);
- number->scale = i;
- wchar* dst = number->digits;
- _ASSERTE(dst != NULL);
- while (--i >= 0) *dst++ = *p++;
- *dst = 0;
-
-
-}
-
-void UInt32ToNumber(unsigned int value, NUMBER* number)
-{
- WRAPPER_NO_CONTRACT
- _ASSERTE(number != NULL);
-
- wchar buffer[UINT32_PRECISION+1];
- number->precision = UINT32_PRECISION;
- number->sign = 0;
- wchar* p = COMNumber::Int32ToDecChars(buffer + UINT32_PRECISION, value, 0);
- _ASSERT(p != NULL);
- int i = (int) (buffer + UINT32_PRECISION - p);
- number->scale = i;
- wchar* dst = number->digits;
- _ASSERT(dst != NULL);
- while (--i >= 0) *dst++ = *p++;
- *dst = 0;
-}
-
-
-
-
-#define LO32(x) ((unsigned int)(x))
-#define HI32(x) ((unsigned int)(((x) & UI64(0xFFFFFFFF00000000)) >> 32))
-
-STRINGREF Int64ToDecStr(__int64 value, int digits, STRINGREF sNegative)
-{
- CONTRACTL {
- THROWS;
- INJECT_FAULT(COMPlusThrowOM());
- GC_TRIGGERS;
- MODE_COOPERATIVE;
- } CONTRACTL_END;
-
- CQuickBytes buf;
-
- if (digits < 1) digits = 1;
- int sign = HI32(value);
-
- // digits as specified in the format string can be at most 99.
- UINT maxDigitsLength = (digits > 20) ? digits : 20;
- UINT bufferLength = (maxDigitsLength > 100) ? maxDigitsLength : 100;
-
- if (sign < 0) {
- value = -value;
- _ASSERTE(sNegative);
- int negLength = sNegative->GetStringLength();
- if ((UINT) negLength > bufferLength - maxDigitsLength) {
- bufferLength = negLength + maxDigitsLength;
- }
- }
-
- wchar *buffer = (wchar*)buf.AllocThrows(bufferLength * sizeof(WCHAR));
- wchar* p = buffer + bufferLength;
- while (HI32(value)) {
- p = COMNumber::Int32ToDecChars(p, Int64DivMod1E9((unsigned __int64*)&value), 9);
- _ASSERTE(p != NULL);
- digits -= 9;
- }
- p = COMNumber::Int32ToDecChars(p, LO32(value), digits);
- _ASSERTE(p != NULL);
- if (sign < 0) {
- wchar* src = sNegative->GetBuffer();
- _ASSERTE(src != NULL);
- for (int i =sNegative->GetStringLength() - 1; i >= 0; i--)
- {
- *(--p) = *(src+i);
- }
- }
- return StringObject::NewString(p, (int) (buffer + bufferLength - p));
-}
-
-STRINGREF UInt64ToDecStr(unsigned __int64 value, int digits)
-{
- WRAPPER_NO_CONTRACT
-
- wchar buffer[100];
- if (digits < 1) digits = 1;
- wchar* p = buffer + 100;
- while (HI32(value)) {
- p = COMNumber::Int32ToDecChars(p, Int64DivMod1E9(&value), 9);
- _ASSERTE(p != NULL);
- digits -= 9;
- }
- p = COMNumber::Int32ToDecChars(p, LO32(value), digits);
- _ASSERTE(p != NULL && p >= buffer && p < (buffer + 100));
- return StringObject::NewString(p, (int) (buffer + 100 - p));
-}
-
-STRINGREF Int64ToHexStr(unsigned __int64 value, int hexBase, int digits)
-{
- WRAPPER_NO_CONTRACT
-
- wchar buffer[100];
- wchar* p;
- if (HI32(value)) {
- Int32ToHexChars(buffer + 100, LO32(value), hexBase, 8);
- p = Int32ToHexChars(buffer + 100 - 8, HI32(value), hexBase, digits - 8);
- }
- else {
- if (digits < 1) digits = 1;
- p = Int32ToHexChars(buffer + 100, LO32(value), hexBase, digits);
- }
- _ASSERTE(p != NULL && p >= buffer && p < (buffer + 100));
- return StringObject::NewString(p, (int) (buffer + 100 - p));
-}
-
-void Int64ToNumber(__int64 value, NUMBER* number)
-{
- WRAPPER_NO_CONTRACT
-
- wchar buffer[INT64_PRECISION+1];
- number->precision = INT64_PRECISION;
- if (value >= 0) {
- number->sign = 0;
- }
- else {
- number->sign = 1;
- value = -value;
- }
- wchar* p = buffer + INT64_PRECISION;
- while (HI32(value)) {
- p = COMNumber::Int32ToDecChars(p, Int64DivMod1E9((unsigned __int64*)&value), 9);
- _ASSERTE(p != NULL);
- }
- p = COMNumber::Int32ToDecChars(p, LO32(value), 0);
- _ASSERTE(p != NULL);
- int i = (int) (buffer + INT64_PRECISION - p);
- number->scale = i;
- wchar* dst = number->digits;
- _ASSERTE(dst != NULL);
- while (--i >= 0) *dst++ = *p++;
- *dst = 0;
-
-}
-
-void UInt64ToNumber(unsigned __int64 value, NUMBER* number)
-{
- WRAPPER_NO_CONTRACT
-
- wchar buffer[UINT64_PRECISION+1];
- number->precision = UINT64_PRECISION;
- number->sign = 0;
- wchar* p = buffer + UINT64_PRECISION;
- while (HI32(value)) {
- p = COMNumber::Int32ToDecChars(p, Int64DivMod1E9(&value), 9);
- _ASSERTE(p != NULL);
- }
- p = COMNumber::Int32ToDecChars(p, LO32(value), 0);
- _ASSERTE(p != NULL);
- int i = (int) (buffer + UINT64_PRECISION - p);
- number->scale = i;
- wchar* dst = number->digits;
- _ASSERTE(dst != NULL);
- while (--i >= 0) *dst++ = *p++;
- *dst = 0;
-
-}
void RoundNumber(NUMBER* number, int pos)
{
@@ -2578,254 +2268,6 @@ lExit: ;
}
FCIMPLEND
-FCIMPL3(Object*, COMNumber::FormatInt32, INT32 value, StringObject* formatUNSAFE, NumberFormatInfo* numfmtUNSAFE)
-{
- FCALL_CONTRACT;
-
- wchar fmt;
- int digits;
-
- struct _gc
- {
- STRINGREF refFormat;
- NUMFMTREF refNumFmt;
- STRINGREF refRetString;
- } gc;
-
- gc.refFormat = (STRINGREF)formatUNSAFE;
- gc.refNumFmt = (NUMFMTREF)numfmtUNSAFE;
- gc.refRetString = NULL;
-
- HELPER_METHOD_FRAME_BEGIN_RET_PROTECT(gc);
-
-
- if (gc.refNumFmt == 0) COMPlusThrowArgumentNull(W("NumberFormatInfo"));
- fmt = ParseFormatSpecifier(gc.refFormat, &digits);
-
- //ANDing fmt with FFDF has the effect of uppercasing the character because
- //we've removed the bit that marks lower-case.
- switch (fmt & 0xFFDF) {
- case 'G':
- if (digits > 0)
- {
- NUMBER number;
- Int32ToNumber(value, &number);
- if (fmt != 0) {
- gc.refRetString = NumberToString(&number, fmt, digits, gc.refNumFmt);
- break;
- }
- gc.refRetString = NumberToStringFormat(&number, gc.refFormat, gc.refNumFmt);
- break;
- }
- // fall through
- case 'D':
- gc.refRetString = Int32ToDecStr(value, digits, gc.refNumFmt->sNegative);
- break;
- case 'X':
- //The fmt-(X-A+10) has the effect of dictating whether we produce uppercase
- //or lowercase hex numbers for a-f. 'X' as the fmt code produces uppercase. 'x'
- //as the format code produces lowercase.
- gc.refRetString = Int32ToHexStr(value, fmt - ('X' - 'A' + 10), digits);
- break;
- default:
- NUMBER number;
- Int32ToNumber(value, &number);
- if (fmt != 0) {
- gc.refRetString = NumberToString(&number, fmt, digits, gc.refNumFmt);
- break;
- }
- gc.refRetString = NumberToStringFormat(&number, gc.refFormat, gc.refNumFmt);
- break;
-
- }
-
- HELPER_METHOD_FRAME_END();
-
- return OBJECTREFToObject(gc.refRetString);
-}
-FCIMPLEND
-
-FCIMPL3(Object*, COMNumber::FormatUInt32, UINT32 value, StringObject* formatUNSAFE, NumberFormatInfo* numfmtUNSAFE)
-{
- FCALL_CONTRACT;
-
- wchar fmt;
- int digits;
-
- struct _gc
- {
- STRINGREF refFormat;
- NUMFMTREF refNumFmt;
- STRINGREF refRetString;
- } gc;
-
- gc.refFormat = (STRINGREF)formatUNSAFE;
- gc.refNumFmt = (NUMFMTREF)numfmtUNSAFE;
- gc.refRetString = NULL;
-
- HELPER_METHOD_FRAME_BEGIN_RET_PROTECT(gc);
-
-
- if (gc.refNumFmt == 0) COMPlusThrowArgumentNull(W("NumberFormatInfo"));
- fmt = ParseFormatSpecifier(gc.refFormat, &digits);
- switch (fmt & 0xFFDF)
- {
- case 'G':
- if (digits > 0)
- {
- NUMBER number;
- UInt32ToNumber(value, &number);
- if (fmt != 0) {
- gc.refRetString = NumberToString(&number, fmt, digits, gc.refNumFmt);
- break;
- }
- gc.refRetString = NumberToStringFormat(&number, gc.refFormat, gc.refNumFmt);
- break;
- }
- // fall through
- case 'D':
- gc.refRetString = UInt32ToDecStr(value, digits);
- break;
- case 'X':
- gc.refRetString = Int32ToHexStr(value, fmt - ('X' - 'A' + 10), digits);
- break;
- default:
- NUMBER number;
- UInt32ToNumber(value, &number);
- if (fmt != 0) {
- gc.refRetString = NumberToString(&number, fmt, digits, gc.refNumFmt);
- break;
- }
- gc.refRetString = NumberToStringFormat(&number, gc.refFormat, gc.refNumFmt);
- break;
- }
-
- HELPER_METHOD_FRAME_END();
-
- return OBJECTREFToObject(gc.refRetString);
-}
-FCIMPLEND
-
-FCIMPL3_VII(Object*, COMNumber::FormatInt64, INT64 value, StringObject* formatUNSAFE, NumberFormatInfo* numfmtUNSAFE)
-{
- FCALL_CONTRACT;
-
- wchar fmt;
- int digits;
-
- struct _gc
- {
- STRINGREF refFormat;
- NUMFMTREF refNumFmt;
- STRINGREF refRetString;
- } gc;
-
- gc.refFormat = ObjectToSTRINGREF(formatUNSAFE);
- gc.refNumFmt = (NUMFMTREF)numfmtUNSAFE;
- gc.refRetString = NULL;
-
- HELPER_METHOD_FRAME_BEGIN_RET_PROTECT(gc);
-
-
- if (gc.refNumFmt == 0) COMPlusThrowArgumentNull(W("NumberFormatInfo"));
- fmt = ParseFormatSpecifier(gc.refFormat, &digits);
- switch (fmt & 0xFFDF)
- {
- case 'G':
- if (digits > 0)
- {
- NUMBER number;
- Int64ToNumber(value, &number);
- if (fmt != 0) {
- gc.refRetString = NumberToString(&number, fmt, digits, gc.refNumFmt);
- break;
- }
- gc.refRetString = NumberToStringFormat(&number, gc.refFormat, gc.refNumFmt);
- break;
- }
- // fall through
- case 'D':
- gc.refRetString = Int64ToDecStr(value, digits, gc.refNumFmt->sNegative);
- break;
- case 'X':
- gc.refRetString = Int64ToHexStr(value, fmt - ('X' - 'A' + 10), digits);
- break;
- default:
- NUMBER number;
- Int64ToNumber(value, &number);
- if (fmt != 0) {
- gc.refRetString = NumberToString(&number, fmt, digits, gc.refNumFmt);
- break;
- }
- gc.refRetString = NumberToStringFormat(&number, gc.refFormat, gc.refNumFmt);
- break;
- }
- HELPER_METHOD_FRAME_END();
-
- return OBJECTREFToObject(gc.refRetString);
-}
-FCIMPLEND
-
-FCIMPL3_VII(Object*, COMNumber::FormatUInt64, UINT64 value, StringObject* formatUNSAFE, NumberFormatInfo* numfmtUNSAFE)
-{
- FCALL_CONTRACT;
-
- wchar fmt;
- int digits;
-
- struct _gc
- {
- STRINGREF refFormat;
- NUMFMTREF refNumFmt;
- STRINGREF refRetString;
- } gc;
-
- gc.refFormat = ObjectToSTRINGREF(formatUNSAFE);
- gc.refNumFmt = (NUMFMTREF)numfmtUNSAFE;
- gc.refRetString = NULL;
-
- HELPER_METHOD_FRAME_BEGIN_RET_PROTECT(gc);
-
- if (gc.refNumFmt == 0) COMPlusThrowArgumentNull(W("NumberFormatInfo"));
- fmt = ParseFormatSpecifier(gc.refFormat, &digits);
- switch (fmt & 0xFFDF) {
- case 'G':
- if (digits > 0)
- {
- NUMBER number;
- UInt64ToNumber(value, &number);
- if (fmt != 0) {
- gc.refRetString = NumberToString(&number, fmt, digits, gc.refNumFmt);
- break;
- }
- gc.refRetString = NumberToStringFormat(&number, gc.refFormat, gc.refNumFmt);
- break;
- }
- // fall through
- case 'D':
- gc.refRetString = UInt64ToDecStr(value, digits);
- break;
- case 'X':
- gc.refRetString = Int64ToHexStr(value, fmt - ('X' - 'A' + 10), digits);
- break;
- default:
- NUMBER number;
- UInt64ToNumber(value, &number);
- if (fmt != 0) {
- gc.refRetString = NumberToString(&number, fmt, digits, gc.refNumFmt);
- break;
- }
- gc.refRetString = NumberToStringFormat(&number, gc.refFormat, gc.refNumFmt);
- break;
- }
-
- HELPER_METHOD_FRAME_END();
-
- return OBJECTREFToObject(gc.refRetString);
-}
-FCIMPLEND
-
-
FCIMPL2(FC_BOOL_RET, COMNumber::NumberBufferToDecimal, BYTE* number, DECIMAL* value)
{
FCALL_CONTRACT;
diff --git a/src/classlibnative/bcltype/number.h b/src/classlibnative/bcltype/number.h
index 7b5efc4485..77f902fb41 100644
--- a/src/classlibnative/bcltype/number.h
+++ b/src/classlibnative/bcltype/number.h
@@ -34,10 +34,6 @@ public:
static FCDECL3_VII(Object*, FormatDecimal, FC_DECIMAL value, StringObject* formatUNSAFE, NumberFormatInfo* numfmtUNSAFE);
static FCDECL3_VII(Object*, FormatDouble, double value, StringObject* formatUNSAFE, NumberFormatInfo* numfmtUNSAFE);
static FCDECL3_VII(Object*, FormatSingle, float value, StringObject* formatUNSAFE, NumberFormatInfo* numfmtUNSAFE);
- static FCDECL3(Object*, FormatInt32, INT32 value, StringObject* formatUNSAFE, NumberFormatInfo* numfmtUNSAFE);
- static FCDECL3(Object*, FormatUInt32, UINT32 value, StringObject* formatUNSAFE, NumberFormatInfo* numfmtUNSAFE);
- static FCDECL3_VII(Object*, FormatInt64, INT64 value, StringObject* formatUNSAFE, NumberFormatInfo* numfmtUNSAFE);
- static FCDECL3_VII(Object*, FormatUInt64, UINT64 value, StringObject* formatUNSAFE, NumberFormatInfo* numfmtUNSAFE);
static FCDECL2(FC_BOOL_RET, NumberBufferToDecimal, BYTE* number, DECIMAL* value);
static FCDECL2(FC_BOOL_RET, NumberBufferToDouble, BYTE* number, double* value);
diff --git a/src/mscorlib/shared/System/Number.Formatting.cs b/src/mscorlib/shared/System/Number.Formatting.cs
index 59afc923f3..066ef0c761 100644
--- a/src/mscorlib/shared/System/Number.Formatting.cs
+++ b/src/mscorlib/shared/System/Number.Formatting.cs
@@ -162,15 +162,6 @@ namespace System
}
}
- internal static unsafe void Int32ToDecChars(char[] buffer, ref int index, uint value, int digits)
- {
- while (--digits >= 0 || value != 0)
- {
- buffer[--index] = (char)(value % 10 + '0');
- value /= 10;
- }
- }
-
[MethodImpl(MethodImplOptions.AggressiveInlining)] // called from only one location
private static unsafe void Int32ToNumber(int value, ref NumberBuffer number)
{
@@ -264,11 +255,9 @@ namespace System
while (--digits >= 0 || value != 0)
{
// TODO https://github.com/dotnet/coreclr/issues/3439
- uint div = value / 10;
- uint rem = value - (div * 10);
-
- value = div;
- *(--bufferEnd) = (char)('0' + rem);
+ uint newValue = value / 10;
+ *(--bufferEnd) = (char)(value - (newValue * 10) + '0');
+ value = newValue;
}
return bufferEnd;
}
@@ -285,10 +274,8 @@ namespace System
{
// TODO https://github.com/dotnet/coreclr/issues/3439
uint div = value / 10;
- uint rem = value - (div * 10);
-
+ *(--p) = (char)('0' + value - (div * 10));
value = div;
- *(--p) = (char)('0' + rem);
}
while (value != 0);
@@ -315,7 +302,6 @@ namespace System
char* buffer = number.digits;
char* p = buffer + Int64Precision;
- int index = Int64Precision;
while (High32(value) != 0)
p = UInt32ToDecChars(p, Int64DivMod1E9(ref value), 9);
p = UInt32ToDecChars(p, Low32(value), 0);
@@ -421,32 +407,6 @@ namespace System
return new string(p, 0, (int)(buffer + bufferSize - p));
}
- internal static unsafe bool TryStringToNumber(ReadOnlySpan<char> str, NumberStyles options, ref NumberBuffer number, ref ValueStringBuilder sb, NumberFormatInfo numfmt, bool parseDecimal)
- {
- Debug.Assert(numfmt != null);
-
- fixed (char* stringPointer = &str.DangerousGetPinnableReference())
- {
- char* p = stringPointer;
- if (!ParseNumber(ref p, options, ref number, ref sb, numfmt, parseDecimal)
- || (p - stringPointer < str.Length && !TrailingZeros(str, (int)(p - stringPointer))))
- {
- return false;
- }
- }
-
- return true;
- }
-
- internal static unsafe void Int32ToDecChars(char* buffer, ref int index, uint value, int digits)
- {
- while (--digits >= 0 || value != 0)
- {
- buffer[--index] = (char)(value % 10 + '0');
- value /= 10;
- }
- }
-
internal static unsafe char ParseFormatSpecifier(string format, out int digits)
{
if (format != null)
@@ -1010,14 +970,6 @@ namespace System
}
}
- private static unsafe int wcslen(char* s)
- {
- int result = 0;
- while (*s++ != '\0')
- result++;
- return result;
- }
-
private static unsafe void FormatFixed(ref ValueStringBuilder sb, ref NumberBuffer number, int nMinDigits, int nMaxDigits, NumberFormatInfo info, int[] groupDigits, string sDecimal, string sGroup)
{
int digPos = number.scale;
@@ -1025,7 +977,7 @@ namespace System
if (digPos > 0)
{
- int digLength = wcslen(dig);
+ int digLength = string.wcslen(dig);
if (groupDigits != null)
{
@@ -1330,7 +1282,7 @@ namespace System
private static uint Low32(ulong value) => (uint)value;
- private static uint High32(ulong value) => (uint)(((ulong)value & 0xFFFFFFFF00000000) >> 32);
+ private static uint High32(ulong value) => (uint)((value & 0xFFFFFFFF00000000) >> 32);
private static uint Int64DivMod1E9(ref ulong value)
{
diff --git a/src/mscorlib/shared/System/Number.Parsing.cs b/src/mscorlib/shared/System/Number.Parsing.cs
index f7f597eee9..fcf5a28710 100644
--- a/src/mscorlib/shared/System/Number.Parsing.cs
+++ b/src/mscorlib/shared/System/Number.Parsing.cs
@@ -381,7 +381,7 @@ namespace System
return i;
}
- private unsafe static bool ParseNumber(ref char* str, NumberStyles options, ref NumberBuffer number, ref ValueStringBuilder sb, NumberFormatInfo numfmt, bool parseDecimal)
+ private unsafe static bool ParseNumber(ref char* str, NumberStyles options, ref NumberBuffer number, NumberFormatInfo numfmt, bool parseDecimal)
{
const int StateSign = 0x0001;
const int StateParens = 0x0002;
@@ -414,9 +414,6 @@ namespace System
}
int state = 0;
- bool bigNumber = !sb.IsDefault; // When a ValueStringBuilder is provided then we use it in place of the number.digits char[50]
- int maxParseDigits = bigNumber ? int.MaxValue : NumberMaxDigits;
-
char* p = str;
char ch = *p;
char* next;
@@ -460,14 +457,11 @@ namespace System
{
state |= StateDigits;
- if (ch != '0' || (state & StateNonZero) != 0 || (bigNumber && ((options & NumberStyles.AllowHexSpecifier) != 0)))
+ if (ch != '0' || (state & StateNonZero) != 0)
{
- if (digCount < maxParseDigits)
+ if (digCount < NumberMaxDigits)
{
- if (bigNumber)
- sb.Append(ch);
- else
- number.digits[digCount++] = ch;
+ number.digits[digCount++] = ch;
if (ch != '0' || parseDecimal)
{
digEnd = digCount;
@@ -502,10 +496,7 @@ namespace System
bool negExp = false;
number.precision = digEnd;
- if (bigNumber)
- sb.Append('\0');
- else
- number.digits[digEnd] = '\0';
+ number.digits[digEnd] = '\0';
if ((state & StateDigits) != 0)
{
if ((ch == 'E' || ch == 'e') && ((options & NumberStyles.AllowExponent) != 0))
@@ -853,8 +844,7 @@ namespace System
fixed (char* stringPointer = &str.DangerousGetPinnableReference())
{
char* p = stringPointer;
- ValueStringBuilder defaultBuilder = default;
- if (!ParseNumber(ref p, options, ref number, ref defaultBuilder, info, parseDecimal)
+ if (!ParseNumber(ref p, options, ref number, info, parseDecimal)
|| (p - stringPointer < str.Length && !TrailingZeros(str, (int)(p - stringPointer))))
{
throw new FormatException(SR.Format_InvalidString);
@@ -868,8 +858,7 @@ namespace System
fixed (char* stringPointer = &str.DangerousGetPinnableReference())
{
char* p = stringPointer;
- ValueStringBuilder defaultBuilder = default;
- if (!ParseNumber(ref p, options, ref number, ref defaultBuilder, numfmt, parseDecimal)
+ if (!ParseNumber(ref p, options, ref number, numfmt, parseDecimal)
|| (p - stringPointer < str.Length && !TrailingZeros(str, (int)(p - stringPointer))))
{
return false;
diff --git a/src/vm/ecalllist.h b/src/vm/ecalllist.h
index 35bd0c7614..b1f9b2b2c3 100644
--- a/src/vm/ecalllist.h
+++ b/src/vm/ecalllist.h
@@ -751,10 +751,6 @@ FCFuncEnd()
FCFuncStart(gNumberFuncs)
FCFuncElement("FormatDecimal", COMNumber::FormatDecimal)
FCFuncElement("FormatDouble", COMNumber::FormatDouble)
- FCFuncElement("FormatInt32", COMNumber::FormatInt32)
- FCFuncElement("FormatUInt32", COMNumber::FormatUInt32)
- FCFuncElement("FormatInt64", COMNumber::FormatInt64)
- FCFuncElement("FormatUInt64", COMNumber::FormatUInt64)
FCFuncElement("FormatSingle", COMNumber::FormatSingle)
FCFuncElement("NumberBufferToDecimal", COMNumber::NumberBufferToDecimal)
FCFuncElement("NumberBufferToDouble", COMNumber::NumberBufferToDouble)