Skip to content

Commit fb0730f

Browse files
committed
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.
1 parent 75cc755 commit fb0730f

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

src/util.h

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -361,22 +361,9 @@ GIT_INLINE(void) git__memzero(void *data, size_t size)
361361

362362
GIT_INLINE(double) git__timer(void)
363363
{
364-
/* We need the initial tick count to detect if the tick
365-
* count has rolled over. */
366-
static DWORD initial_tick_count = 0;
367-
368-
/* GetTickCount returns the number of milliseconds that have
364+
/* GetTickCount64 returns the number of milliseconds that have
369365
* elapsed since the system was started. */
370-
DWORD count = GetTickCount();
371-
372-
if(initial_tick_count == 0) {
373-
initial_tick_count = count;
374-
} else if (count < initial_tick_count) {
375-
/* The tick count has rolled over - adjust for it. */
376-
count = (0xFFFFFFFF - initial_tick_count) + count;
377-
}
378-
379-
return (double) count / (double) 1000;
366+
return (double) GetTickCount64() / (double) 1000;
380367
}
381368

382369
#elif __APPLE__

0 commit comments

Comments
 (0)