Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,15 @@ public virtual object Clone()
ci._textInfo = (TextInfo)_textInfo.Clone();
}

if (_calendar != null)
if (_dateTimeInfo != null && _dateTimeInfo.Calendar == _calendar)
{
// Usually when we access CultureInfo.DateTimeFormat first time, we create the DateTimeFormatInfo object
// using CultureInfo.Calendar. i.e. CultureInfo.DateTimeInfo.Calendar == CultureInfo.calendar.
// When cloning CultureInfo, if we know this still the case CultureInfo.DateTimeInfo.Calendar == CultureInfo.calendar
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: "if we know this still the case" => "if we know it's still the case that"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I already merged the change. I can try to fix that next time I change something in coreclr. thanks for the comment.

// then we can keep the same behavior for the cloned object and no need to create another calendar object.
ci._calendar = ci.DateTimeFormat.Calendar;
}
else if (_calendar != null)
{
ci._calendar = (Calendar)_calendar.Clone();
}
Expand Down