-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
30% optimization of DateTime.GetDate()
/.Year/.Month/.Day/.DayOfYear
by 'Euclidean affine functions'
#72712
Merged
danmoseley
merged 9 commits into
dotnet:main
from
SergeiPavlov:optimize_DateTime_GetDate
Jul 31, 2022
Merged
30% optimization of DateTime.GetDate()
/.Year/.Month/.Day/.DayOfYear
by 'Euclidean affine functions'
#72712
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5cc9503
Optimize DateTime.GetDate()/.GetDatePart() by 'Euclidean affine funct…
SergeiPavlov 4293bfd
Code style
SergeiPavlov 163509c
Refactoring: avoid switch and 'var' keyword; add March1BasedDayOfNewY…
SergeiPavlov dfd20c6
Fix build
SergeiPavlov 06cdd8f
Add [MethodImpl(MethodImplOptions.AggressiveInlining)] to GetDatePart()
SergeiPavlov e5e0ded
revert relevant comments from original code
SergeiPavlov 7503120
Inline calculations into properties: Year, Month, Day, DayOfYear inst…
SergeiPavlov 8f48de6
Fix indentation
SergeiPavlov 7a5531e
align comment
SergeiPavlov 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
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
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.
... Some additional comments, especially around the specific magic numbers, would be greatly appreciated.
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.
These magic number have not explainable meaning. They just give right result.
To understand them it is neccessary to follow chain of propositions in the article.
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.
Then you should at least be noting the source inside the code. If there is any sort of naming for those constants in the source, you should probably be pulling them out into named constants as well.
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 did in the function comment https://github.com/dotnet/runtime/pull/72712/files#diff-5afffb30d8c00fa852b7df6e5bce6255be93acc1281d20b308ab57e8b70f567bR1356
Authors of the algorithm don't use any constant naming in the article and their reference implementation https://github.com/cassioneri/calendar/blob/master/calendar.hpp#L285