Skip to content

Commit 4d3e411

Browse files
committed
libc/time: Eliminate optimization in tzset comparing previous value
Checking to see if tzset is called with the same value as the last time requires that the previous value be stored in memory. As that string can be quite long, that either requires a large static buffer or the use of malloc. Removing this optimization from the library and expecting applications to only call tzset when required saves all of that cost. Signed-off-by: Keith Packard <[email protected]>
1 parent 4b9b8ef commit 4d3e411

File tree

1 file changed

+0
-11
lines changed

1 file changed

+0
-11
lines changed

newlib/libc/time/tzset.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ Supporting OS subroutine required: None
112112

113113
static char __tzname_std[TZNAME_MAX + 2];
114114
static char __tzname_dst[TZNAME_MAX + 2];
115-
static char *prev_tzenv = NULL;
116115

117116
void
118117
_tzset_unlocked (void)
@@ -133,19 +132,9 @@ _tzset_unlocked (void)
133132
_tzname[1] = "GMT";
134133
tz->__tzrule[0] = default_tzrule;
135134
tz->__tzrule[1] = default_tzrule;
136-
free(prev_tzenv);
137-
prev_tzenv = NULL;
138135
return;
139136
}
140137

141-
if (prev_tzenv != NULL && strcmp(tzenv, prev_tzenv) == 0)
142-
return;
143-
144-
free(prev_tzenv);
145-
prev_tzenv = malloc (strlen(tzenv) + 1);
146-
if (prev_tzenv != NULL)
147-
strcpy (prev_tzenv, tzenv);
148-
149138
/* default to unnamed UTC in case of error */
150139
_timezone = 0;
151140
_daylight = 0;

0 commit comments

Comments
 (0)