Keep GNU fastpath for jerry_port_get_local_time_zone_adjustment (#4600)

PR #4513 caused a measurable slowdown by removing the GNU specific TZA calculation.
This patch reverts this removal but also keeps the general implementation introduced in #4513

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
This commit is contained in:
Robert Fancsik
2021-02-17 20:44:00 +01:00
committed by GitHub
parent 112ad83aaa
commit c14702c129
2 changed files with 31 additions and 3 deletions
+15 -3
View File
@@ -59,7 +59,19 @@ static double FileTimeToUnixTimeMs (FILETIME ft)
double jerry_port_get_local_time_zone_adjustment (double unix_ms, /**< ms since unix epoch */
bool is_utc) /**< is the time above in UTC? */
{
#ifdef _WIN32
#if defined (HAVE_TM_GMTOFF)
struct tm tm;
time_t now = (time_t) (unix_ms / 1000);
localtime_r (&now, &tm);
if (!is_utc)
{
now -= tm.tm_gmtoff;
localtime_r (&now, &tm);
}
return ((double) tm.tm_gmtoff) * 1000;
#elif defined (_WIN32)
FILETIME fileTime, localFileTime;
SYSTEMTIME systemTime, localSystemTime;
ULARGE_INTEGER time, localTime;
@@ -111,11 +123,11 @@ double jerry_port_get_local_time_zone_adjustment (double unix_ms, /**< ms since
}
return tza_s * 1000;
#else /* !_WIN32 && !__GNUC__ && !__clang__ */
#else /* !HAVE_TM_GMTOFF && !_WIN32 && !__GNUC__ && !__clang__ */
(void) unix_ms; /* unused */
(void) is_utc; /* unused */
return 0.0;
#endif /* _WIN32 */
#endif /* HAVE_TM_GMTOFF */
} /* jerry_port_get_local_time_zone_adjustment */
/**