diff options
Diffstat (limited to 'src/Ryujinx.Common/SystemInfo/LinuxSystemInfo.cs')
-rw-r--r-- | src/Ryujinx.Common/SystemInfo/LinuxSystemInfo.cs | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/src/Ryujinx.Common/SystemInfo/LinuxSystemInfo.cs b/src/Ryujinx.Common/SystemInfo/LinuxSystemInfo.cs index b0c15e49..08aa452e 100644 --- a/src/Ryujinx.Common/SystemInfo/LinuxSystemInfo.cs +++ b/src/Ryujinx.Common/SystemInfo/LinuxSystemInfo.cs @@ -20,7 +20,7 @@ namespace Ryujinx.Common.SystemInfo { ["model name"] = null, ["Processor"] = null, - ["Hardware"] = null + ["Hardware"] = null, }; ParseKeyValues("/proc/cpuinfo", cpuDict); @@ -31,7 +31,7 @@ namespace Ryujinx.Common.SystemInfo var memDict = new Dictionary<string, string>(StringComparer.Ordinal) { ["MemTotal"] = null, - ["MemAvailable"] = null + ["MemAvailable"] = null, }; ParseKeyValues("/proc/meminfo", memDict); @@ -56,25 +56,30 @@ namespace Ryujinx.Common.SystemInfo int count = itemDict.Count; - using (StreamReader file = new StreamReader(filePath)) + using StreamReader file = new(filePath); + + string line; + while ((line = file.ReadLine()) != null) { - string line; - while ((line = file.ReadLine()) != null) + string[] kvPair = line.Split(':', 2, StringSplitOptions.TrimEntries); + + if (kvPair.Length < 2) { - string[] kvPair = line.Split(':', 2, StringSplitOptions.TrimEntries); + continue; + } - if (kvPair.Length < 2) continue; + string key = kvPair[0]; - string key = kvPair[0]; + if (itemDict.TryGetValue(key, out string value) && value == null) + { + itemDict[key] = kvPair[1]; - if (itemDict.TryGetValue(key, out string value) && value == null) + if (--count <= 0) { - itemDict[key] = kvPair[1]; - - if (--count <= 0) break; + break; } } } } } -}
\ No newline at end of file +} |