Here's another possibility for speeding up zdump: remember the "ats" index used in the last call to localtime and, when appropriate, start the search there. (If you do this, you don't want to simply do a binary search since you might already have the correct answer). --ado ------- localtime.c ------- *** /tmp/geta15068 Mon Mar 6 11:09:53 2006 --- /tmp/getb15068 Mon Mar 6 11:09:53 2006 *************** *** 5,11 **** #ifndef lint #ifndef NOID ! static char elsieid[] = "@(#)localtime.c 8.1"; #endif /* !defined NOID */ #endif /* !defined lint */ --- 5,11 ---- #ifndef lint #ifndef NOID ! static char elsieid[] = "@(#)localtime.c 8.2"; #endif /* !defined NOID */ #endif /* !defined lint */ *************** *** 1263,1272 **** break; } } else { ! for (i = 1; i < sp->timecnt; ++i) if (t < sp->ats[i]) break; i = (int) sp->types[i - 1]; } ttisp = &sp->ttis[i]; /* --- 1263,1287 ---- break; } } else { ! /* ! ** Since "guess" is just a guess and is validated before use, ! ** its staticness does not affect thread safeness. ! */ ! static int guess; ! ! i = guess; ! if (i < 1 || i >= sp->timecnt || t < sp->ats[i]) ! i = 1; ! for ( ; i < sp->timecnt; ++i) if (t < sp->ats[i]) break; i = (int) sp->types[i - 1]; + /* + ** Heuristic alert: + ** the "- 1" below caters to programs such as zdump that do + ** lots of calls straddling a particular transition time. + */ + guess = i - 1; } ttisp = &sp->ttis[i]; /*