[Wine-patches] [PATCH 4/4] kernel32: Optimize GetLocalTime.

Alexander Morozov =?iso-8859-1?q?amorozov_=CE=C1_etersoft=2Eru?=
Вт Апр 7 16:54:18 MSD 2009


---
 dlls/kernel32/time.c |   22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/dlls/kernel32/time.c b/dlls/kernel32/time.c
index 95a6b60..e1b787e 100644
--- a/dlls/kernel32/time.c
+++ b/dlls/kernel32/time.c
@@ -911,14 +911,28 @@ INT WINAPI CompareFileTime( const FILETIME *x, const FILETIME *y )
  */
 VOID WINAPI GetLocalTime(LPSYSTEMTIME systime)
 {
+    static int lock = 0;
+    static SYSTEMTIME old_systime;
+    static LARGE_INTEGER old;
     FILETIME lft;
     LARGE_INTEGER ft, ft2;
 
+    while (interlocked_cmpxchg(&lock, 1, 0));
     NtQuerySystemTime(&ft);
-    RtlSystemTimeToLocalTime(&ft, &ft2);
-    lft.dwLowDateTime = ft2.u.LowPart;
-    lft.dwHighDateTime = ft2.u.HighPart;
-    FileTimeToSystemTime(&lft, systime);
+    if (ft.QuadPart == old.QuadPart)
+    {
+        *systime = old_systime;
+    }
+    else
+    {
+        RtlSystemTimeToLocalTime(&ft, &ft2);
+        lft.dwLowDateTime = ft2.u.LowPart;
+        lft.dwHighDateTime = ft2.u.HighPart;
+        FileTimeToSystemTime(&lft, systime);
+        old = ft;
+        old_systime = *systime;
+    }
+    interlocked_xchg(&lock, 0);
 }
 
 /*********************************************************************
-- 
1.6.1.3.GIT



Подробная информация о списке рассылки Wine-patches