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 <hjk@theqtcompany.com>
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
This commit is contained in:
Orgad Shaneh
2015-07-22 23:32:12 +03:00
committed by Orgad Shaneh
parent 9bcb933008
commit adf3a4363f

View File

@@ -38,12 +38,20 @@
using namespace Utils; using namespace Utils;
#ifdef Q_OS_WIN
static WORD hostProcessorArchitecture()
{
SYSTEM_INFO info;
GetNativeSystemInfo(&info);
return info.wProcessorArchitecture;
}
#endif
HostOsInfo::HostArchitecture HostOsInfo::hostArchitecture() HostOsInfo::HostArchitecture HostOsInfo::hostArchitecture()
{ {
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
SYSTEM_INFO info; static const WORD processorArchitecture = hostProcessorArchitecture();
GetNativeSystemInfo(&info); switch (processorArchitecture) {
switch (info.wProcessorArchitecture) {
case PROCESSOR_ARCHITECTURE_AMD64: case PROCESSOR_ARCHITECTURE_AMD64:
return HostOsInfo::HostArchitectureAMD64; return HostOsInfo::HostArchitectureAMD64;
case PROCESSOR_ARCHITECTURE_INTEL: case PROCESSOR_ARCHITECTURE_INTEL: