diff options
author | Ron Yorston <rmy@pobox.com> | 2018-11-27 10:04:27 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2018-11-27 10:49:16 +0000 |
commit | 0ecf1e541e1cf550724b0a5dd3a5c74cf807f36b (patch) | |
tree | c880a8608a5559881a96a2986f53eb24cd2b7dd8 /win32 | |
parent | 5a38b2b6e34c51b8c419e57822b195e3156b756f (diff) | |
download | busybox-w32-0ecf1e541e1cf550724b0a5dd3a5c74cf807f36b.tar.gz busybox-w32-0ecf1e541e1cf550724b0a5dd3a5c74cf807f36b.tar.bz2 busybox-w32-0ecf1e541e1cf550724b0a5dd3a5c74cf807f36b.zip |
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.
Diffstat (limited to 'win32')
-rw-r--r-- | win32/process.c | 21 |
1 files changed, 7 insertions, 14 deletions
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 | |||
517 | if ((proc=OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, | 517 | if ((proc=OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, |
518 | FALSE, pe.th32ProcessID))) { | 518 | FALSE, pe.th32ProcessID))) { |
519 | if (GetProcessTimes(proc, &crTime, &exTime, &keTime, &usTime)) { | 519 | if (GetProcessTimes(proc, &crTime, &exTime, &keTime, &usTime)) { |
520 | /* times in ticks since 1 January 1601 */ | 520 | long long ticks_since_boot, boot_time, create_time; |
521 | static long long boot_time = 0; | 521 | FILETIME now; |
522 | long long start_time; | ||
523 | 522 | ||
524 | if (boot_time == 0) { | 523 | ticks_since_boot = GetTickCount64()/MS_PER_TICK; |
525 | long long ticks_since_boot; | 524 | GetSystemTimeAsFileTime(&now); |
526 | FILETIME now; | 525 | boot_time = filetime_to_ticks(&now) - ticks_since_boot; |
527 | 526 | create_time = filetime_to_ticks(&crTime); | |
528 | ticks_since_boot = GetTickCount64()/MS_PER_TICK; | ||
529 | GetSystemTimeAsFileTime(&now); | ||
530 | boot_time = filetime_to_ticks(&now) - ticks_since_boot; | ||
531 | } | ||
532 | |||
533 | start_time = filetime_to_ticks(&crTime); | ||
534 | sp->start_time = (unsigned long)(start_time - boot_time); | ||
535 | 527 | ||
528 | sp->start_time = (unsigned long)(create_time - boot_time); | ||
536 | sp->stime = (unsigned long)filetime_to_ticks(&keTime); | 529 | sp->stime = (unsigned long)filetime_to_ticks(&keTime); |
537 | sp->utime = (unsigned long)filetime_to_ticks(&usTime); | 530 | sp->utime = (unsigned long)filetime_to_ticks(&usTime); |
538 | } | 531 | } |