Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

Port TimeZoneInfo cleanups from CoreCLR #2400

Merged
merged 7 commits into from
Dec 20, 2016
Merged

Port TimeZoneInfo cleanups from CoreCLR #2400

merged 7 commits into from
Dec 20, 2016

Conversation

justinvp
Copy link
Contributor

Contributes to #2388

Ports the following:
dotnet/coreclr#8513 (this change was already in CoreRT)
dotnet/coreclr#8526
dotnet/coreclr#8527
dotnet/coreclr#8528
dotnet/coreclr#8529
dotnet/coreclr#8530
dotnet/coreclr#8540
dotnet/coreclr#8575

There's one more left to port (dotnet/coreclr#8512) that I'll submit as a separate PR as it requires some minor refactoring in CoreRT to avoid having the Sort code in multiple places in CoreRT (it's only in one place in CoreCLR).

cc: @tarekgh, @DnlHarvey, @jkotas

TimeZoneInfo is immutable. Help enforce this by making its fields
readonly.
AdjustmentRule is immutable. Help enforce this by making its fields
readonly.
TransitionTime is immutable. Help enforce this by making its fields
readonly.
There doesn't appear to be a good reason why the TimeZoneInfo.Utc
instance needs to be cleared when TimeZoneInfo.ClearCachedData() is
called. Instead, we can pre-allocate and reuse a singleton instance,
obviating the need for the lazy-initialization/locking mechanics.
It's more efficient to concatenate the strings.
TimeZoneInfo currently always creates a defensive copy of the specified
ArgumentRule[] array when created. This makes sense for the public
static factory methods. However, there's no need to create a defensive
copy of arrays created privately as part of its implementation (e.g.
reading the rules from the registry/disk). This change avoids the
unnecessary cloning.
@tarekgh
Copy link
Member

tarekgh commented Dec 20, 2016

LGTM. thanks a lot @justinvp

@tarekgh tarekgh merged commit 8211cc6 into dotnet:master Dec 20, 2016
@justinvp justinvp deleted the tzi branch December 21, 2016 18:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants