]> granicus.if.org Git - php/commitdiff
Optimize sapi_get_request_time() slightly making it use the cached time
authorRasmus Lerdorf <rasmus@php.net>
Fri, 25 May 2007 09:19:05 +0000 (09:19 +0000)
committerRasmus Lerdorf <rasmus@php.net>
Fri, 25 May 2007 09:19:05 +0000 (09:19 +0000)
and also checking if there is a server_context before trying to call
the request_time sapi hook.

main/SAPI.c

index 08f9e68963434a75f53291948f673c82c4432be0..3f8becd221f5ab657628b7dcf412bb08cb24404f 100644 (file)
@@ -920,12 +920,14 @@ SAPI_API int sapi_get_target_gid(gid_t *obj TSRMLS_DC)
 
 SAPI_API time_t sapi_get_request_time(TSRMLS_D)
 {
-       if (sapi_module.get_request_time) {
-               return sapi_module.get_request_time(TSRMLS_C);
+       if(SG(global_request_time)) return SG(global_request_time);
+
+       if (sapi_module.get_request_time && SG(server_context)) {
+               SG(global_request_time) = sapi_module.get_request_time(TSRMLS_C);
        } else {
-               if(!SG(global_request_time)) SG(global_request_time) = time(0);
-               return SG(global_request_time);
+               SG(global_request_time) = time(0);
        }
+       return SG(global_request_time);
 }
 
 /*