Commit fb0730f1f3957b41fa0dd2594fb7d0214b2594da

Tobias Nießen 2019-04-16T23:49:16

util: use 64 bit timer on Windows git__timer was originally implemented using a 32 bit timer since Windows XP did not support GetTickCount64. Windows XP was discontinued five years ago, so it should be safe to use the new API. As a benefit, we do not need to care about overflows for the next 585 million years.

diff --git a/src/util.h b/src/util.h
index b9ab652..6f49653 100644
--- a/src/util.h
+++ b/src/util.h
@@ -361,22 +361,9 @@ GIT_INLINE(void) git__memzero(void *data, size_t size)
 
 GIT_INLINE(double) git__timer(void)
 {
-	/* We need the initial tick count to detect if the tick
-	 * count has rolled over. */
-	static DWORD initial_tick_count = 0;
-
-	/* GetTickCount returns the number of milliseconds that have
+	/* GetTickCount64 returns the number of milliseconds that have
 	 * elapsed since the system was started. */
-	DWORD count = GetTickCount();
-
-	if(initial_tick_count == 0) {
-		initial_tick_count = count;
-	} else if (count < initial_tick_count) {
-		/* The tick count has rolled over - adjust for it. */
-		count = (0xFFFFFFFF - initial_tick_count) + count;
-	}
-
-	return (double) count / (double) 1000;
+	return (double) GetTickCount64() / (double) 1000;
 }
 
 #elif __APPLE__