1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-14 18:42:34 +03:00

Avoid repeated computation of the constants date2j(1970, 1, 1) and

date2j(2000, 1, 1).  Should make for some marginal speed improvement
in date/time operations.
This commit is contained in:
Tom Lane
2003-04-04 04:50:44 +00:00
parent 3b4ca4c0d9
commit d685417fbb
7 changed files with 91 additions and 72 deletions

View File

@ -328,18 +328,7 @@ pg_stat_get_backend_activity_start(PG_FUNCTION_ARGS)
if (sec == 0 && usec == 0)
PG_RETURN_NULL();
/*
* This method of converting "Unix time" (sec/usec since epoch) to a
* PostgreSQL timestamp is an ugly hack -- if you fix it, be sure to
* fix the similar hackery in timestamp.c
*/
#ifdef HAVE_INT64_TIMESTAMP
result = (((sec - ((date2j(2000, 1, 1) - date2j(1970, 1, 1)) * 86400))
* INT64CONST(1000000)) + usec);
#else
result = (sec + (usec * 1.0e-6) - ((date2j(2000, 1, 1) -
date2j(1970, 1, 1)) * 86400));
#endif
result = AbsoluteTimeUsecToTimestampTz(sec, usec);
PG_RETURN_TIMESTAMPTZ(result);
}