30% optimization of `DateTime.GetDate()`/`.Year/.Month/.Day/.DayOfYear` by 'Euclidean...
authorSergei Pavlov <spavlov@servicetitan.com>
Sun, 31 Jul 2022 15:07:22 +0000 (08:07 -0700)
committerGitHub <noreply@github.com>
Sun, 31 Jul 2022 15:07:22 +0000 (16:07 +0100)
commit85beaecef75ed20c26d83a77b86b9f961fbb9de2
tree93f6d927317b35f43306e097313dd899609b8437
parent5e6df13ec83bc3046fd6eb9816970fe380b430ed
30% optimization of `DateTime.GetDate()`/`.Year/.Month/.Day/.DayOfYear` by 'Euclidean affine functions' (#72712)

* Optimize DateTime.GetDate()/.GetDatePart() by 'Euclidean affine functions'

* Code style

* Refactoring: avoid switch and 'var' keyword; add March1BasedDayOfNewYear constant

* Fix build

* Add [MethodImpl(MethodImplOptions.AggressiveInlining)] to GetDatePart()

* revert relevant comments from original code

* Inline calculations into properties: Year, Month, Day, DayOfYear instead of Common GetDatePart() function

* Fix indentation

* align comment
src/libraries/System.Private.CoreLib/src/System/DateTime.cs