From fd316bc594750e538afc9a980f850e442afe229a Mon Sep 17 00:00:00 2001 From: Vladyslav Baranovskyi Date: Fri, 20 Dec 2024 16:46:13 +0200 Subject: [PATCH 1/6] Changed Get*Name to return const std::string& --- openVulkanoCpp/Host/SystemInfo.hpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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(); From 718fadca15bf3155e487c842616745ec2695a2d6 Mon Sep 17 00:00:00 2001 From: Vladyslav Baranovskyi Date: Fri, 20 Dec 2024 16:46:39 +0200 Subject: [PATCH 2/6] SystemInfo changes for Linux --- openVulkanoCpp/Host/Linux/SystemInfo.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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; } From dadc025ebea6b050752023344e91efe8cbce8863 Mon Sep 17 00:00:00 2001 From: Vladyslav Baranovskyi Date: Fri, 20 Dec 2024 16:46:50 +0200 Subject: [PATCH 3/6] SystemInfo changes for MacOS --- openVulkanoCpp/Host/MacOS/SystemInfo.mm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/openVulkanoCpp/Host/MacOS/SystemInfo.mm b/openVulkanoCpp/Host/MacOS/SystemInfo.mm index b5d4d41..a5bf82f 100644 --- a/openVulkanoCpp/Host/MacOS/SystemInfo.mm +++ b/openVulkanoCpp/Host/MacOS/SystemInfo.mm @@ -62,29 +62,29 @@ namespace OpenVulkano return 0; } - std::string SystemInfo::GetUserName() + const std::string& SystemInfo::GetUserName() { return ""; } - 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"; } - std::string SystemInfo::GetDeviceModelName() + const std::string& SystemInfo::GetDeviceModelName() { static std::string machine; if (machine.empty()) @@ -96,7 +96,7 @@ namespace OpenVulkano return machine; } - std::string SystemInfo::GetOsName() + const std::string& SystemInfo::GetOsName() { return "MacOS"; } @@ -113,7 +113,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; From 305b841c552c7ee0a0b27f8ed80f1cb3c0752774 Mon Sep 17 00:00:00 2001 From: Vladyslav Baranovskyi Date: Fri, 20 Dec 2024 16:47:00 +0200 Subject: [PATCH 4/6] SystemInfo changes for Windows --- openVulkanoCpp/Host/Windows/SystemInfo.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/openVulkanoCpp/Host/Windows/SystemInfo.cpp b/openVulkanoCpp/Host/Windows/SystemInfo.cpp index 2f4eecc..72e17ee 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,7 +419,7 @@ namespace OpenVulkano return deviceModelName; } - std::string SystemInfo::GetOsName() + const std::string& SystemInfo::GetOsName() { return "Windows"; } @@ -439,7 +439,7 @@ namespace OpenVulkano return osVersion; } - std::string SystemInfo::GetOsNameHumanReadable() + const std::string& SystemInfo::GetOsNameHumanReadable() { static const std::string osName = GetHumanReadableOSName(); return osName; From 3748c9b150586993952ef04e63ec14ae96f243e2 Mon Sep 17 00:00:00 2001 From: Vladyslav Baranovskyi Date: Fri, 20 Dec 2024 16:47:05 +0200 Subject: [PATCH 5/6] SystemInfo changes for iOS --- openVulkanoCpp/Host/iOS/SystemInfo.mm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/openVulkanoCpp/Host/iOS/SystemInfo.mm b/openVulkanoCpp/Host/iOS/SystemInfo.mm index af0c922..54efb7e 100644 --- a/openVulkanoCpp/Host/iOS/SystemInfo.mm +++ b/openVulkanoCpp/Host/iOS/SystemInfo.mm @@ -64,29 +64,29 @@ namespace OpenVulkano return 0; } - std::string SystemInfo::GetUserName() + const std::string& SystemInfo::GetUserName() { return ""; } - 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"; } - std::string SystemInfo::GetDeviceModelName() + const std::string& SystemInfo::GetDeviceModelName() { static std::string modelName; if (modelName.empty()) @@ -99,7 +99,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 +117,7 @@ namespace OpenVulkano return osv; } - std::string SystemInfo::GetOsNameHumanReadable() + const std::string& SystemInfo::GetOsNameHumanReadable() { static std::string hrName; if (hrName.empty()) From b37b8dc6397cac92d870c8ae10669cf29b57f795 Mon Sep 17 00:00:00 2001 From: Vladyslav Baranovskyi Date: Fri, 20 Dec 2024 17:02:32 +0200 Subject: [PATCH 6/6] Introduced static variables in places where the return value is a plain string --- openVulkanoCpp/Host/MacOS/SystemInfo.mm | 9 ++++++--- openVulkanoCpp/Host/Windows/SystemInfo.cpp | 3 ++- openVulkanoCpp/Host/iOS/SystemInfo.mm | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/openVulkanoCpp/Host/MacOS/SystemInfo.mm b/openVulkanoCpp/Host/MacOS/SystemInfo.mm index a5bf82f..ca295f6 100644 --- a/openVulkanoCpp/Host/MacOS/SystemInfo.mm +++ b/openVulkanoCpp/Host/MacOS/SystemInfo.mm @@ -64,7 +64,8 @@ namespace OpenVulkano const std::string& SystemInfo::GetUserName() { - return ""; + static const std::string userName = ""; + return userName; } const std::string& SystemInfo::GetHostName() @@ -81,7 +82,8 @@ namespace OpenVulkano const std::string& SystemInfo::GetDeviceVendorName() { - return "Apple"; + static const std::string vendorName = "Apple"; + return vendorName; } const std::string& SystemInfo::GetDeviceModelName() @@ -98,7 +100,8 @@ namespace OpenVulkano const std::string& SystemInfo::GetOsName() { - return "MacOS"; + static const std::string osName = "MacOS"; + return osName; } OsVersion SystemInfo::GetOsVersion() diff --git a/openVulkanoCpp/Host/Windows/SystemInfo.cpp b/openVulkanoCpp/Host/Windows/SystemInfo.cpp index 72e17ee..a7a9270 100644 --- a/openVulkanoCpp/Host/Windows/SystemInfo.cpp +++ b/openVulkanoCpp/Host/Windows/SystemInfo.cpp @@ -421,7 +421,8 @@ namespace OpenVulkano const std::string& SystemInfo::GetOsName() { - return "Windows"; + static const std::string osName = "Windows"; + return osName; } OsVersion SystemInfo::GetOsVersion() diff --git a/openVulkanoCpp/Host/iOS/SystemInfo.mm b/openVulkanoCpp/Host/iOS/SystemInfo.mm index 54efb7e..3182ba2 100644 --- a/openVulkanoCpp/Host/iOS/SystemInfo.mm +++ b/openVulkanoCpp/Host/iOS/SystemInfo.mm @@ -66,7 +66,8 @@ namespace OpenVulkano const std::string& SystemInfo::GetUserName() { - return ""; + static const std::string userName = ""; + return userName; } const std::string& SystemInfo::GetHostName() @@ -83,7 +84,8 @@ namespace OpenVulkano const std::string& SystemInfo::GetDeviceVendorName() { - return "Apple"; + static const std::string vendorName = "Apple"; + return vendorName; } const std::string& SystemInfo::GetDeviceModelName()