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.
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
[libs][Unix][perf] Lazily initialize TimeZoneInfo names and order GetSystemTimeZones by Ids #88368
Changes from 12 commits
0935950
032b737
4a00b1f
0e95c88
580a765
4adb545
ec41439
b43beab
e933ea0
25ea2bb
b0cd70b
b453345
6d113e0
e60c1a4
3ffa389
a47ea8c
8d4bc4f
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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
?