Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libs][Unix][perf] Lazily initialize TimeZoneInfo names and order GetSystemTimeZones by Ids #88368

Merged
merged 17 commits into from
Jul 10, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix internal field naming
  • Loading branch information
mdh1418 committed Jul 5, 2023
commit ec41439052300b5c13f0541e78c2726a6542e9e1
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public sealed partial class TimeZoneInfo

// Set fallback values using abbreviations, base offset, and id
// These are expected in environments without time zone globalization data
private string? s_standardAbbrevName;
private string? s_daylightAbbrevName;
private string? _standardAbbrevName;
private string? _daylightAbbrevName;

// Handle UTC and its aliases per https://github.com/unicode-org/cldr/blob/master/common/bcp47/timezone.xml
// Hard-coded because we need to treat all aliases of UTC the same even when globalization data is not available.
Expand Down Expand Up @@ -81,11 +81,11 @@ private TimeZoneInfo(byte[] data, string id, bool dstDisabled)
if (!transitionType[type].IsDst)
{
_baseUtcOffset = transitionType[type].UtcOffset;
s_standardAbbrevName = TZif_GetZoneAbbreviation(zoneAbbreviations, transitionType[type].AbbreviationIndex);
_standardAbbrevName = TZif_GetZoneAbbreviation(zoneAbbreviations, transitionType[type].AbbreviationIndex);
}
else
{
s_daylightAbbrevName = TZif_GetZoneAbbreviation(zoneAbbreviations, transitionType[type].AbbreviationIndex);
_daylightAbbrevName = TZif_GetZoneAbbreviation(zoneAbbreviations, transitionType[type].AbbreviationIndex);
}
}

Expand All @@ -98,11 +98,11 @@ private TimeZoneInfo(byte[] data, string id, bool dstDisabled)
if (!transitionType[i].IsDst)
{
_baseUtcOffset = transitionType[i].UtcOffset;
s_standardAbbrevName = TZif_GetZoneAbbreviation(zoneAbbreviations, transitionType[i].AbbreviationIndex);
_standardAbbrevName = TZif_GetZoneAbbreviation(zoneAbbreviations, transitionType[i].AbbreviationIndex);
}
else
{
s_daylightAbbrevName = TZif_GetZoneAbbreviation(zoneAbbreviations, transitionType[i].AbbreviationIndex);
_daylightAbbrevName = TZif_GetZoneAbbreviation(zoneAbbreviations, transitionType[i].AbbreviationIndex);
}
}
}
Expand Down Expand Up @@ -246,7 +246,7 @@ public AdjustmentRule[] GetAdjustmentRules()
if (IsUtcAlias(Id))
return GetUtcStandardDisplayName();

string? standardDisplayName = s_standardAbbrevName;
string? standardDisplayName = _standardAbbrevName;
if (GlobalizationMode.Invariant)
return standardDisplayName;

Expand All @@ -264,7 +264,7 @@ public AdjustmentRule[] GetAdjustmentRules()
if (IsUtcAlias(Id))
return StandardName;

string? daylightDisplayName = s_daylightAbbrevName ?? s_standardAbbrevName;
string? daylightDisplayName = _daylightAbbrevName ?? _standardAbbrevName;
if (GlobalizationMode.Invariant)
return daylightDisplayName;

Expand Down