From: Ralph Corderoy Date: Fri, 11 Nov 2016 00:38:29 +0000 (+0000) Subject: dlocaltime(): Only call tzset(3) once. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/c762fa39172dee2133e0a5d6324464a4fa3cff50?ds=sidebyside dlocaltime(): Only call tzset(3) once. This avoids the stat(2) of /etc/localtime per message scan if TZ isn't set in the environment; that's the default case on this Linux system. I can't see a way the TZ environment variable is likely to change between messages, or that it's intended an invocation of scan(1), say, copes with the timezone shifting underneath it by /etc/localtime being changed. --- diff --git a/sbr/dtime.c b/sbr/dtime.c index 066a72d7..89f5dde8 100644 --- a/sbr/dtime.c +++ b/sbr/dtime.c @@ -108,7 +108,14 @@ dlocaltime (time_t *clock) if (tm->tm_isdst) /* if DST is in effect */ tw.tw_zone -= 60; /* reset to normal offset */ #else - tzset(); + { + static bool deja_vu; + + if (!deja_vu) { + deja_vu = true; + tzset(); + } + } tw.tw_zone = -(timezone / 60); #endif