From d8eeec5629fc5a3ca0b198514768b347d5d4b31d Mon Sep 17 00:00:00 2001 From: Arthur David Olson Date: Thu, 2 May 1996 15:06:00 -0400 Subject: [PATCH] more early time work SCCS-file: zic.c SCCS-SID: 7.69 --- zic.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/zic.c b/zic.c index 75012ff..6f89d95 100644 --- a/zic.c +++ b/zic.c @@ -1340,9 +1340,33 @@ const char * const name; time_t ats[TZ_MAX_TIMES]; unsigned char types[TZ_MAX_TIMES]; + /* + ** Sort. + */ if (timecnt > 1) (void) qsort((void *) attypes, (size_t) timecnt, (size_t) sizeof *attypes, atcomp); + /* + ** Optimize. + */ + { + int fromi; + int toi; + + toi = 0; + fromi = 0; + if (isdsts[0] == 0) + while (attypes[fromi].type == 0) + ++fromi; /* handled by default rule */ + for ( ; fromi < timecnt; ++fromi) + if (toi == 0 || + attypes[toi - 1].type != attypes[fromi].type) + attypes[toi++] = attypes[fromi]; + timecnt = toi; + } + /* + ** Transfer. + */ for (i = 0; i < timecnt; ++i) { ats[i] = attypes[i].at; types[i] = attypes[i].type; @@ -1642,10 +1666,6 @@ addtt(starttime, type) const time_t starttime; const int type; { - if (timecnt != 0 && type == attypes[timecnt - 1].type) - return; /* easy enough! */ - if (timecnt == 0 && type == 0 && isdsts[0] == 0) - return; /* handled by default rule */ if (timecnt >= TZ_MAX_TIMES) { error(_("too many transitions?!")); (void) exit(EXIT_FAILURE);