From 0ecf1e541e1cf550724b0a5dd3a5c74cf807f36b Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Tue, 27 Nov 2018 10:04:27 +0000 Subject: win32: save a few bytes in process scanning Recalculate the system boot time on every pass through the process scanning loop. It's less efficient than storing the value in a static variable but not noticeably so and it saves a few bytes. --- win32/process.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'win32') diff --git a/win32/process.c b/win32/process.c index e074d44e4..1c409a20e 100644 --- a/win32/process.c +++ b/win32/process.c @@ -517,22 +517,15 @@ UNUSED_PARAM if ((proc=OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, pe.th32ProcessID))) { if (GetProcessTimes(proc, &crTime, &exTime, &keTime, &usTime)) { - /* times in ticks since 1 January 1601 */ - static long long boot_time = 0; - long long start_time; + long long ticks_since_boot, boot_time, create_time; + FILETIME now; - if (boot_time == 0) { - long long ticks_since_boot; - FILETIME now; - - ticks_since_boot = GetTickCount64()/MS_PER_TICK; - GetSystemTimeAsFileTime(&now); - boot_time = filetime_to_ticks(&now) - ticks_since_boot; - } - - start_time = filetime_to_ticks(&crTime); - sp->start_time = (unsigned long)(start_time - boot_time); + ticks_since_boot = GetTickCount64()/MS_PER_TICK; + GetSystemTimeAsFileTime(&now); + boot_time = filetime_to_ticks(&now) - ticks_since_boot; + create_time = filetime_to_ticks(&crTime); + sp->start_time = (unsigned long)(create_time - boot_time); sp->stime = (unsigned long)filetime_to_ticks(&keTime); sp->utime = (unsigned long)filetime_to_ticks(&usTime); } -- cgit v1.2.3-55-g6feb