You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improve the performance of ArithmeticDate.until() (unicode-org#7739)
Improve the performnace of the calendar `until()` function.
- Tighten the estimation of the number of months between two dates in
order to reduce the number of incremental `surpasses()` tests. This is
done by introducing a new DateFieldsResolver function,
`min_months_from()`, which the Coptic, Ethiopic, and Hebrew calendar
implementations customize.
- Eliminate the `surpasses()` loop for the final days delta calculation.
Instead compute an intermediate date, which is the start date plus the
years, months, and weeks computed so far. Subtract the Rata Die of the
intermediate date from that of the target date to get the days field of
the DateDuration.
- Fix minor typos in function names and comments.
Performance, as measured using criterion, is improved for Years and
Months intervals. Improvements on the order of 20% to 80%, or 100s of ns
to >1 ms, are shown, for base times of 500 ns to 5 ms.
For Weeks and Days, which are already computed efficiently using RD
subtraction, criterion measures a slight slowdown (on the order of 1 ns,
for a 15-20 ns operation). This is most likely due to a change in
compiler inlining, optimization, register usage, etc., since the code
for Days/Weeks has not changed.
<!--
Thank you for your pull request to ICU4X!
Reminder: try to use [Conventional
Comments](https://conventionalcomments.org/) to make comments clearer.
Please see
https://github.com/unicode-org/icu4x/blob/main/CONTRIBUTING.md for
general
information on contributing to ICU4X.
-->
0 commit comments