diff --git a/openVulkanoCpp/Host/Linux/SystemInfo.cpp b/openVulkanoCpp/Host/Linux/SystemInfo.cpp index a47e77e..19fe0cf 100644 --- a/openVulkanoCpp/Host/Linux/SystemInfo.cpp +++ b/openVulkanoCpp/Host/Linux/SystemInfo.cpp @@ -112,7 +112,7 @@ namespace OpenVulkano return vramMax; } - std::string SystemInfo::GetUserName() + const std::string& SystemInfo::GetUserName() { static std::string userName; if (userName.empty()) @@ -130,7 +130,7 @@ namespace OpenVulkano return userName; } - std::string SystemInfo::GetHostName() + const std::string& SystemInfo::GetHostName() { static std::string hostName; if (hostName.empty()) @@ -142,12 +142,12 @@ namespace OpenVulkano return hostName; } - std::string SystemInfo::GetDeviceName() + const std::string& SystemInfo::GetDeviceName() { return GetHostName(); } - std::string SystemInfo::GetDeviceVendorName() + const std::string& SystemInfo::GetDeviceVendorName() { static std::string vendor; if (vendor.empty()) @@ -168,7 +168,7 @@ namespace OpenVulkano return vendor; } - std::string SystemInfo::GetDeviceModelName() + const std::string& SystemInfo::GetDeviceModelName() { static std::string modelName; if (modelName.empty()) @@ -283,7 +283,7 @@ namespace OpenVulkano OsInfo osInfo; } - std::string SystemInfo::GetOsName() + const std::string& SystemInfo::GetOsName() { return osInfo.osName; } @@ -293,7 +293,7 @@ namespace OpenVulkano return osInfo.version; } - std::string SystemInfo::GetOsNameHumanReadable() + const std::string& SystemInfo::GetOsNameHumanReadable() { return osInfo.osNameFormatted; } diff --git a/openVulkanoCpp/Host/MacOS/SystemInfo.mm b/openVulkanoCpp/Host/MacOS/SystemInfo.mm index b5d4d41..ca295f6 100644 --- a/openVulkanoCpp/Host/MacOS/SystemInfo.mm +++ b/openVulkanoCpp/Host/MacOS/SystemInfo.mm @@ -62,29 +62,31 @@ namespace OpenVulkano return 0; } - std::string SystemInfo::GetUserName() + const std::string& SystemInfo::GetUserName() { - return ""; + static const std::string userName = ""; + return userName; } - std::string SystemInfo::GetHostName() + const std::string& SystemInfo::GetHostName() { static const std::string hostName = [[NSProcessInfo processInfo].hostName UTF8String]; return hostName; } - std::string SystemInfo::GetDeviceName() + const std::string& SystemInfo::GetDeviceName() { static const std::string devName = "Mac"; //TODO return devName; } - std::string SystemInfo::GetDeviceVendorName() + const std::string& SystemInfo::GetDeviceVendorName() { - return "Apple"; + static const std::string vendorName = "Apple"; + return vendorName; } - std::string SystemInfo::GetDeviceModelName() + const std::string& SystemInfo::GetDeviceModelName() { static std::string machine; if (machine.empty()) @@ -96,9 +98,10 @@ namespace OpenVulkano return machine; } - std::string SystemInfo::GetOsName() + const std::string& SystemInfo::GetOsName() { - return "MacOS"; + static const std::string osName = "MacOS"; + return osName; } OsVersion SystemInfo::GetOsVersion() @@ -113,7 +116,7 @@ namespace OpenVulkano return osVersion; } - std::string SystemInfo::GetOsNameHumanReadable() + const std::string& SystemInfo::GetOsNameHumanReadable() { static const std::string hrName = fmt::format("{} {}", GetOsName(), GetOsVersion().major); return hrName; diff --git a/openVulkanoCpp/Host/SystemInfo.hpp b/openVulkanoCpp/Host/SystemInfo.hpp index b42ed10..7ab324c 100644 --- a/openVulkanoCpp/Host/SystemInfo.hpp +++ b/openVulkanoCpp/Host/SystemInfo.hpp @@ -36,16 +36,16 @@ namespace OpenVulkano static size_t GetAppRamAvailable(); static size_t GetAppRamUsed(); - static std::string GetUserName(); - static std::string GetHostName(); + static const std::string& GetUserName(); + static const std::string& GetHostName(); // Device name as given by the user - static std::string GetDeviceName(); - static std::string GetDeviceVendorName(); - static std::string GetDeviceModelName(); - static std::string GetOsName(); + static const std::string& GetDeviceName(); + static const std::string& GetDeviceVendorName(); + static const std::string& GetDeviceModelName(); + static const std::string& GetOsName(); static OsVersion GetOsVersion(); - static std::string GetOsNameHumanReadable(); + static const std::string& GetOsNameHumanReadable(); static DeviceType GetDeviceType(); static size_t GetCpuCoreCount(); diff --git a/openVulkanoCpp/Host/Windows/SystemInfo.cpp b/openVulkanoCpp/Host/Windows/SystemInfo.cpp index 2f4eecc..a7a9270 100644 --- a/openVulkanoCpp/Host/Windows/SystemInfo.cpp +++ b/openVulkanoCpp/Host/Windows/SystemInfo.cpp @@ -359,7 +359,7 @@ namespace OpenVulkano return ReadAppMemInfo(APP_MEM_TYPE::VM_MAX); } - std::string SystemInfo::GetUserName() + const std::string& SystemInfo::GetUserName() { static std::string userName; if (userName.empty()) @@ -372,7 +372,7 @@ namespace OpenVulkano return userName; } - std::string SystemInfo::GetHostName() + const std::string& SystemInfo::GetHostName() { static std::string hostName; if (hostName.empty()) @@ -384,7 +384,7 @@ namespace OpenVulkano return hostName; } - std::string SystemInfo::GetDeviceName() + const std::string& SystemInfo::GetDeviceName() { static std::string devName; if (devName.empty()) @@ -397,7 +397,7 @@ namespace OpenVulkano return devName; } - std::string SystemInfo::GetDeviceVendorName() + const std::string& SystemInfo::GetDeviceVendorName() { static std::string vendorName; if (vendorName.empty()) @@ -408,7 +408,7 @@ namespace OpenVulkano return vendorName; } - std::string SystemInfo::GetDeviceModelName() + const std::string& SystemInfo::GetDeviceModelName() { static std::string deviceModelName; if (deviceModelName.empty()) @@ -419,9 +419,10 @@ namespace OpenVulkano return deviceModelName; } - std::string SystemInfo::GetOsName() + const std::string& SystemInfo::GetOsName() { - return "Windows"; + static const std::string osName = "Windows"; + return osName; } OsVersion SystemInfo::GetOsVersion() @@ -439,7 +440,7 @@ namespace OpenVulkano return osVersion; } - std::string SystemInfo::GetOsNameHumanReadable() + const std::string& SystemInfo::GetOsNameHumanReadable() { static const std::string osName = GetHumanReadableOSName(); return osName; diff --git a/openVulkanoCpp/Host/iOS/SystemInfo.mm b/openVulkanoCpp/Host/iOS/SystemInfo.mm index af0c922..3182ba2 100644 --- a/openVulkanoCpp/Host/iOS/SystemInfo.mm +++ b/openVulkanoCpp/Host/iOS/SystemInfo.mm @@ -64,29 +64,31 @@ namespace OpenVulkano return 0; } - std::string SystemInfo::GetUserName() + const std::string& SystemInfo::GetUserName() { - return ""; + static const std::string userName = ""; + return userName; } - std::string SystemInfo::GetHostName() + const std::string& SystemInfo::GetHostName() { static const std::string hostName = [[NSProcessInfo processInfo].hostName UTF8String]; return hostName; } - std::string SystemInfo::GetDeviceName() + const std::string& SystemInfo::GetDeviceName() { static const std::string devName = [[[UIDevice currentDevice] name] UTF8String]; return devName; } - std::string SystemInfo::GetDeviceVendorName() + const std::string& SystemInfo::GetDeviceVendorName() { - return "Apple"; + static const std::string vendorName = "Apple"; + return vendorName; } - std::string SystemInfo::GetDeviceModelName() + const std::string& SystemInfo::GetDeviceModelName() { static std::string modelName; if (modelName.empty()) @@ -99,7 +101,7 @@ namespace OpenVulkano return modelName; } - std::string SystemInfo::GetOsName() + const std::string& SystemInfo::GetOsName() { static const std::string osName = [[[UIDevice currentDevice] systemName] UTF8String]; return osName; @@ -117,7 +119,7 @@ namespace OpenVulkano return osv; } - std::string SystemInfo::GetOsNameHumanReadable() + const std::string& SystemInfo::GetOsNameHumanReadable() { static std::string hrName; if (hrName.empty())