Skip to content

Commit 9d10e33

Browse files
avoid redundant tzset() calls
The tzset() function initializes the tzname variable from the TZ environment variable. There doesn't seem to be any valid usecase of calling this redundantly. It is an overhead that can be avoided. In both the occurances, locatime_r() is called right afterwards, which is documented to also perform the tzset()'s side effects.
1 parent 529a594 commit 9d10e33

File tree

1 file changed

+0
-6
lines changed

1 file changed

+0
-6
lines changed

src/tree_data_common.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,9 +1626,6 @@ ly_time_tz_offset_at(time_t time)
16261626
struct tm tm_local, tm_utc;
16271627
int result = 0;
16281628

1629-
/* init timezone */
1630-
tzset();
1631-
16321629
/* get local and UTC time */
16331630
localtime_r(&time, &tm_local);
16341631
gmtime_r(&time, &tm_utc);
@@ -1776,9 +1773,6 @@ ly_time_time2str(time_t time, const char *fractions_s, char **str)
17761773

17771774
LY_CHECK_ARG_RET(NULL, str, LY_EINVAL);
17781775

1779-
/* init timezone */
1780-
tzset();
1781-
17821776
/* convert */
17831777
if (!localtime_r(&time, &tm)) {
17841778
return LY_ESYS;

0 commit comments

Comments
 (0)