Respond to PR feedback
authorMatt Ellis <matell@microsoft.com>
Tue, 22 Sep 2015 21:47:20 +0000 (14:47 -0700)
committerMatt Ellis <matell@microsoft.com>
Tue, 22 Sep 2015 21:47:20 +0000 (14:47 -0700)
src/corefx/System.Globalization.Native/calendarData.cpp
src/mscorlib/corefx/Interop/Unix/System.Globalization.Native/Interop.Casing.cs
src/mscorlib/corefx/System/Globalization/CalendarData.Unix.cs

index a9c356d..1fc6116 100644 (file)
@@ -23,6 +23,8 @@
 #define ISLAMIC_UMALQURA_NAME "islamic-umalqura"
 #define ROC_NAME "roc"
 
+#define JAPANESE_LOCALE_AND_CALENDAR "ja_JP@calendar=japanese"
+
 /*
 * These values should be kept in sync with System.Globalization.CalendarId
 */
@@ -519,7 +521,7 @@ Gets the latest era in the Japanese calendar.
 extern "C" int32_t GetLatestJapaneseEra()
 {
        UErrorCode err = U_ZERO_ERROR;
-       Locale japaneseLocale("ja_JP@calendar=japanese");
+       Locale japaneseLocale(JAPANESE_LOCALE_AND_CALENDAR);
        LocalPointer<Calendar> calendar(Calendar::createInstance(japaneseLocale, err));
 
        if (U_FAILURE(err))
@@ -540,8 +542,12 @@ extern "C" int32_t GetJapaneseEraStartDate(
        int32_t* startMonth,
        int32_t* startDay)
 {
+       *startYear = -1;
+       *startMonth = -1;
+       *startDay = -1;
+
        UErrorCode err = U_ZERO_ERROR;
-       Locale japaneseLocale("ja_JP@calendar=japanese");
+       Locale japaneseLocale(JAPANESE_LOCALE_AND_CALENDAR);
        LocalPointer<Calendar> calendar(Calendar::createInstance(japaneseLocale, err));
        if (U_FAILURE(err))
                return false;
index 5fdcf30..94f4734 100644 (file)
@@ -10,9 +10,9 @@ internal static partial class Interop
     internal static partial class GlobalizationInterop
     {
         [DllImport(Libraries.GlobalizationInterop, CharSet = CharSet.Unicode)]
-        internal unsafe static extern void ChangeCase(char* src, int srcLen, char* dstBuffer, int dstBufferCapacity, bool bIsUpper, bool bTurkishCasing);
+        internal unsafe static extern void ChangeCase(char* src, int srcLen, char* dstBuffer, int dstBufferCapacity, bool bToUpper, bool bTurkishCasing);
 
         [DllImport(Libraries.GlobalizationInterop, CharSet = CharSet.Unicode)]
-        internal unsafe static extern void ChangeCase(string src, int srcLen, char* dstBuffer, int dstBufferCapacity, bool bIsUpper, bool bTurkishCasing);
+        internal unsafe static extern void ChangeCase(string src, int srcLen, char* dstBuffer, int dstBufferCapacity, bool bToUpper, bool bTurkishCasing);
     }
 }
index cfca8a3..219f796 100644 (file)
@@ -161,7 +161,7 @@ namespace System.Globalization
         /// </remarks>
         private static string NormalizeDatePattern(string input)
         {
-            StringBuilder destination = new StringBuilder(input.Length);
+            StringBuilder destination = StringBuilderCache.Acquire(input.Length);
 
             int index = 0;
             while (index < input.Length)
@@ -237,7 +237,7 @@ namespace System.Globalization
                 }
             }
 
-            return destination.ToString();
+            return StringBuilderCache.GetStringAndRelease(destination);
         }
 
         private static void NormalizeDayOfWeek(string input, StringBuilder destination, ref int index)