-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
0935950
[libs] Remove unnecessary assignment TZifHead
mdh1418 032b737
[libs][perf] Add lazy initialization for TimeZoneInfo names
mdh1418 4a00b1f
Reduce comparisons for UTC alias and remove static array allocation
mdh1418 0e95c88
[libs] Lazy init display names for utc aliases
mdh1418 580a765
[libs][perf] Order system time zones by id
mdh1418 4adb545
Directly compare numerical value
mdh1418 ec41439
Fix internal field naming
mdh1418 b43beab
Remove TryPopulateTimeZoneDisplayNamesFromGlobalizationData
mdh1418 e933ea0
Make lazy initialization methods static on windows
mdh1418 25ea2bb
Revert "[libs][perf] Order system time zones by id"
mdh1418 b0cd70b
Fix lazy initialization for Minimal Globalization Data
mdh1418 b453345
Avoid lazy initialization where internal display name fields are set …
mdh1418 6d113e0
Fix CreateLocal not preserving lazy initialized names
mdh1418 e60c1a4
Prevent unintended lazy initialization in CreateCustomTimeZone
mdh1418 3ffa389
Make UICulture a property
mdh1418 a47ea8c
Substitute null name properties with empty string in default constructor
mdh1418 8d4bc4f
Assert not reached in Invariant mode
mdh1418 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Substitute null name properties with empty string in default constructor
- Loading branch information
commit a47ea8ca28b72bdf33f3f83c52b8575710d0d3a3
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would these ever be called on Windows? if not, then at least assert or throw exception here to catch any future wrong use of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like there could be cases where
_displayName
is stillnull
, like when using the public APIsCreateCustomTimeZone
. So if for some reason someone usedTimeZoneInfo myTzi = CreateCustomTimeZone(<id>, <offset>, null, null, null, <adjustmentRules>)
and later invokedmyTzi.DisplayName
, this would be hit.I think in this case, we should honor that the internal fields have not been set and still return
null
?But thats a good point.... I wouldn't want
TimeZoneInfo
objects created byCreateCustomTimeZone
to have their fields unexpectedly populated (and incur the performance hit) if they intended for them to have anull
value.Would the best way to check that be by having some sort of boolean to track whether or not it had been set as
null
on purpose?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that
CreateCustomTimeZone
sets the names tostring.Empty
if they werenull
, these shouldn't be hit.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added
Debug.Assert(false);
in the window's implementation of these methods.I modified the primary constructor in
TimeZoneInfo.cs
to have?? string.Empty
for the internal fields (and removed the modifications fromCreateCustomTimeZone
as they will eventually flow to this constructor.In doing so, I believe for windows the only other
TimeZoneInfo
constructor that is of interest isruntime/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Win32.cs
Line 113 in cd9d541
Populate*
methods on Windows (unless I'm missing something else)Moreover, this doesn't get used anywhere does it?
runtime/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.cs
Lines 1106 to 1117 in cd9d541
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recall it can be used by some serialization engines like Data Contract serialization. Please keep it for compat.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah even though it is a private constructor and isn't referenced in the
TimeZoneInfo.*.cs
?