From 02b0fe86f26e2a1039edf3d19db681694ee49534 Mon Sep 17 00:00:00 2001 From: jon-chuang Date: Fri, 14 Apr 2023 03:55:33 +0800 Subject: [PATCH] improve --- examples/common.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/examples/common.cpp b/examples/common.cpp index 7ce4d1fcd..65fbb9bbd 100644 --- a/examples/common.cpp +++ b/examples/common.cpp @@ -42,11 +42,10 @@ int32_t get_num_physical_cores() { int result = sysctlbyname("hw.perflevel0.physicalcpu", &num_physical_cores, &len, NULL, 0); if (result == 0) { return (int32_t) num_physical_cores; - } else { - int result = sysctlbyname("hw.physicalcpu", &num_physical_cores, &len, NULL, 0); - if (result == 0) { - return (int32_t) num_physical_cores; - } + } + result = sysctlbyname("hw.physicalcpu", &num_physical_cores, &len, NULL, 0); + if (result == 0) { + return (int32_t) num_physical_cores; } #elif defined(_WIN32) SYSTEM_INFO sysinfo;