Removed redundant if statements where possible

This commit is contained in:
Vladyslav Baranovskyi
2024-12-20 16:10:10 +02:00
parent 90440b3f34
commit 947faebe9c
4 changed files with 20 additions and 81 deletions

View File

@@ -27,11 +27,7 @@ namespace OpenVulkano
size_t SystemInfo::GetSystemRam()
{
static size_t ram;
if (ram == 0)
{
ram = [NSProcessInfo processInfo].physicalMemory;
}
static const size_t ram = [NSProcessInfo processInfo].physicalMemory;
return ram;
}
@@ -75,21 +71,13 @@ namespace OpenVulkano
std::string SystemInfo::GetHostName()
{
static std::string hostName;
if (hostName.empty())
{
hostName = [[NSProcessInfo processInfo].hostName UTF8String];
}
static const std::string hostName = [[NSProcessInfo processInfo].hostName UTF8String];
return hostName;
}
std::string SystemInfo::GetDeviceName()
{
static std::string devName;
if (devName.empty())
{
devName = [[[UIDevice currentDevice] name] UTF8String];
}
static const std::string devName = [[[UIDevice currentDevice] name] UTF8String];
return devName;
}
@@ -113,17 +101,13 @@ namespace OpenVulkano
std::string SystemInfo::GetOsName()
{
static std::string osName;
if (osName.empty())
{
osName = [[[UIDevice currentDevice] systemName] UTF8String];
}
static const std::string osName = [[[UIDevice currentDevice] systemName] UTF8String];
return osName;
}
OsVersion SystemInfo::GetOsVersion()
{
static OsVersion osv;
static OsVersion osv = {};
if (osv.major == 0 && osv.minor == 0)
{
NSOperatingSystemVersion osVersion = [NSProcessInfo processInfo].operatingSystemVersion;
@@ -170,21 +154,13 @@ namespace OpenVulkano
size_t SystemInfo::GetCpuCoreCount()
{
static size_t coreCount;
if (coreCount == 0)
{
coreCount = [NSProcessInfo processInfo].processorCount;
}
static const size_t coreCount = [NSProcessInfo processInfo].processorCount;
return coreCount;
}
size_t SystemInfo::GetCpuThreadCount()
{
static size_t threadCount;
if (threadCount == 0)
{
threadCount = [NSProcessInfo processInfo].activeProcessorCount;
}
static const size_t threadCount = [NSProcessInfo processInfo].activeProcessorCount;
return threadCount;
}