summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2014-12-23 12:02:36 +0100
committerAnatol Belski <ab@php.net>2014-12-23 13:00:30 +0100
commitbc33171ac639381cd6a04d46a069290b468b4270 (patch)
tree7361e46eb90753704b51e83e85ac7c8f6bd03c74 /win32
parente60b7207db5e3611c8c613ff986a524b62e6eb7d (diff)
downloadphp-git-bc33171ac639381cd6a04d46a069290b468b4270.tar.gz
improved system time function determination
It doesn't need to LoadLibrary and all that stuff every time, but once on the first access. Also the functions which are not directly used inlined now.
Diffstat (limited to 'win32')
-rw-r--r--win32/time.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/win32/time.c b/win32/time.c
index 75539748e8..9b5030a0f2 100644
--- a/win32/time.c
+++ b/win32/time.c
@@ -27,7 +27,9 @@
typedef VOID (WINAPI *MyGetSystemTimeAsFileTime)(LPFILETIME lpSystemTimeAsFileTime);
-static MyGetSystemTimeAsFileTime get_time_func(void)
+static MyGetSystemTimeAsFileTime timefunc = NULL;
+
+static zend_always_inline MyGetSystemTimeAsFileTime get_time_func(void)
{
MyGetSystemTimeAsFileTime timefunc = NULL;
HMODULE hMod = LoadLibrary("kernel32.dll");
@@ -45,19 +47,16 @@ static MyGetSystemTimeAsFileTime get_time_func(void)
return timefunc;
}
-int getfilesystemtime(struct timeval *tv)
+static zend_always_inline int getfilesystemtime(struct timeval *tv)
{
FILETIME ft;
unsigned __int64 ff = 0;
- MyGetSystemTimeAsFileTime timefunc;
ULARGE_INTEGER fft;
- timefunc = get_time_func();
- if (timefunc) {
- timefunc(&ft);
- } else {
- GetSystemTimeAsFileTime(&ft);
+ if (!timefunc) {
+ timefunc = get_time_func();
}
+ timefunc(&ft);
/*
* Do not cast a pointer to a FILETIME structure to either a