time: faster still

Huw D M Davies h.davies1 at physics.ox.ac.uk
Tue Feb 24 07:53:23 CST 2004


        Huw Davies <huw at codeweavers.com>
        RtlSystemTimeToLocalTime will always be slow, so cache the bias.
-- 
Huw Davies
huw at codeweavers.com
Index: dlls/kernel/time.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel/time.c,v
retrieving revision 1.38
diff -u -r1.38 time.c
--- dlls/kernel/time.c	23 Jan 2004 01:51:34 -0000	1.38
+++ dlls/kernel/time.c	24 Feb 2004 13:50:22 -0000
@@ -845,9 +845,19 @@
 {
     FILETIME lft;
     LARGE_INTEGER ft, ft2;
+    static BOOL bias_set = FALSE;
+    static LONGLONG bias;
 
     NtQuerySystemTime(&ft);
-    RtlSystemTimeToLocalTime(&ft, &ft2);
+    if(!bias_set)
+    {
+        RtlSystemTimeToLocalTime(&ft, &ft2);
+        bias = ft2.QuadPart - ft.QuadPart;
+        bias_set = TRUE;
+    }
+    else
+        ft2.QuadPart = ft.QuadPart + bias;
+
     lft.dwLowDateTime = ft2.u.LowPart;
     lft.dwHighDateTime = ft2.u.HighPart;
     FileTimeToSystemTime(&lft, systime);



More information about the wine-patches mailing list