[tz] [PROPOSED] zic performance tweak for wide-ranging years
Paul Eggert
eggert at cs.ucla.edu
Fri Jun 1 21:02:32 UTC 2018
* zic.c (rpytime): Improve performance when the year
is outlandishly small or large.
---
zic.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/zic.c b/zic.c
index 7c04435..679b3e2 100644
--- a/zic.c
+++ b/zic.c
@@ -3141,6 +3141,15 @@ rpytime(const struct rule *rp, zic_t wantedy)
dayoff = 0;
m = TM_JANUARY;
y = EPOCH_YEAR;
+ if (y < wantedy) {
+ wantedy -= y;
+ dayoff = (wantedy / YEARSPERREPEAT) * (SECSPERREPEAT / SECSPERDAY);
+ wantedy %= YEARSPERREPEAT;
+ wantedy += y;
+ } else if (wantedy < 0) {
+ dayoff = (wantedy / YEARSPERREPEAT) * (SECSPERREPEAT / SECSPERDAY);
+ wantedy %= YEARSPERREPEAT;
+ }
while (wantedy != y) {
if (wantedy > y) {
i = len_years[isleap(y)];
--
2.17.0
More information about the tz
mailing list