-
Notifications
You must be signed in to change notification settings - Fork 517
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
Optimize NaiveDate::add_days
for small values
#1214
Conversation
That must have been one of the longer days in history... With a small change in
More seriously: we have reasonable but not exhaustive coverage for values within a year, for values that cross the year boundary and have to account for leap years, and for values than can cause an overflow in Adding more tests does not seem that useful to me. |
I think the confidence this provides is worth the relatively small amount of work. (admittedly, I'm not doing the work! though if you want me to then I can submit a PR for my suggestion) |
13089cb
to
28c85aa
Compare
Codecov Report
@@ Coverage Diff @@
## 0.4.x #1214 +/- ##
=======================================
Coverage 91.40% 91.41%
=======================================
Files 38 38
Lines 16932 16959 +27
=======================================
+ Hits 15477 15503 +26
- Misses 1455 1456 +1
... and 3 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@djc Did you want to give this a second look? Or was #1214 (comment) only a question and is this approved? |
I expect this method to be used much more often with small values than with values that end up an x number of years into the past or future. So I would like to add a fast path.
In the common case where the result of
add_checked_signed
and similar ends up within the same year we can avoid a couple of divisions and lookups and just change the ordinal.Before:
After: