From adf3a4363fffdb3288d771433f9fb27342ac3cad Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Wed, 22 Jul 2015 23:32:12 +0300 Subject: [PATCH] Utils: Avoid multiple calls to GetNativeSystemInfo on Windows In fact, hostArchitecture is only called on MSVC auto-detection, which is only done on startup. On the other hand, all the other functions in HostOsInfo are independent on external calls, so adapt this one in case it is used in the future. Change-Id: I4646d87cb3b976e358276482cad1b14bfc430964 Reviewed-by: hjk Reviewed-by: Eike Ziller Reviewed-by: David Schulz --- src/libs/utils/hostosinfo.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/libs/utils/hostosinfo.cpp b/src/libs/utils/hostosinfo.cpp index 7a7f18122ea..c60ce91b498 100644 --- a/src/libs/utils/hostosinfo.cpp +++ b/src/libs/utils/hostosinfo.cpp @@ -38,12 +38,20 @@ using namespace Utils; +#ifdef Q_OS_WIN +static WORD hostProcessorArchitecture() +{ + SYSTEM_INFO info; + GetNativeSystemInfo(&info); + return info.wProcessorArchitecture; +} +#endif + HostOsInfo::HostArchitecture HostOsInfo::hostArchitecture() { #ifdef Q_OS_WIN - SYSTEM_INFO info; - GetNativeSystemInfo(&info); - switch (info.wProcessorArchitecture) { + static const WORD processorArchitecture = hostProcessorArchitecture(); + switch (processorArchitecture) { case PROCESSOR_ARCHITECTURE_AMD64: return HostOsInfo::HostArchitectureAMD64; case PROCESSOR_ARCHITECTURE_INTEL: