Skip to content

Commit

Permalink
Add Invariant check to DateTimeParse tokens codepaths (#53717)
Browse files Browse the repository at this point in the history
Cuts about 7k for invariant mode
  • Loading branch information
marek-safar authored Jun 6, 2021
1 parent b854c93 commit 5b8e178
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2409,7 +2409,7 @@ internal bool Tokenize(TokenType TokenMask, out TokenType tokenType, out int tok
if (isLetter)
{
ch = Culture.TextInfo.ToLower(ch);
if (IsHebrewChar(ch) && TokenMask == TokenType.RegularTokenMask)
if (!GlobalizationMode.Invariant && IsHebrewChar(ch) && TokenMask == TokenType.RegularTokenMask)
{
if (TryParseHebrewNumber(ref str, out bool badFormat, out tokenValue))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,12 @@ private static bool Lex(DS dps, ref __DTString str, ref DateTimeToken dtok, ref
}
break;
case TokenType.JapaneseEraToken:
if (GlobalizationMode.Invariant)
{
Debug.Fail("Should never be reached");
return false;
}

// Special case for Japanese. We allow Japanese era name to be used even if the calendar is not Japanese Calendar.
result.calendar = JapaneseCalendar.GetDefaultInstance();
dtfi = DateTimeFormatInfo.GetJapaneseCalendarDTFI();
Expand All @@ -1066,6 +1072,12 @@ private static bool Lex(DS dps, ref __DTString str, ref DateTimeToken dtok, ref
}
break;
case TokenType.TEraToken:
if (GlobalizationMode.Invariant)
{
Debug.Fail("Should never be reached");
return false;
}

result.calendar = TaiwanCalendar.GetDefaultInstance();
dtfi = DateTimeFormatInfo.GetTaiwanCalendarDTFI();
if (result.era != -1)
Expand Down

0 comments on commit 5b8e178

Please sign in to comment.