Skip to content

Commit 7b49e10

Browse files
author
Charlie Fenton
committed
Mac: make initialization logic easier to understand
1 parent 6cb3e3b commit 7b49e10

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/procinfo_mac.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,15 @@ int procinfo_setup(PROC_MAP& pm) {
178178
// };
179179
//
180180
double total_cpu_time() {
181-
static natural_t processorCount = 0;
181+
static bool first = true;
182+
natural_t processorCount = 0;
182183
processor_cpu_load_info_t cpuLoad;
183184
mach_msg_type_number_t processorMsgCount;
184185
static double scale;
185186
uint64_t totalUserTime = 0;
186187

187-
if (processorCount == 0) {
188+
if (!first) {
189+
first = false;
188190
long hz = sysconf(_SC_CLK_TCK);
189191
scale = 1./hz;
190192
}

0 commit comments

Comments
 (0)