Improve SteamConfiguration performance

This commit is contained in:
Kamil Trzciński 2022-11-28 20:28:21 +01:00
parent 3c209f04b4
commit 190b14e66f
2 changed files with 7 additions and 8 deletions

View file

@ -20,15 +20,14 @@ namespace SteamController.Helpers
private static readonly Regex ControllerBlacklistRegex = new Regex("^(\\s*\"controller_blacklist\"\\s*\")([^\"]*)(\"\\s*)$");
public static bool? IsRunning
public static bool IsRunning
{
get
{
var value = GetValue<int>(ActiveProcessKey, PIDValue);
if (value is null)
return null;
using (var process = SteamProcess)
{
return process is not null;
}
}
}
@ -143,7 +142,7 @@ namespace SteamController.Helpers
while (DateTimeOffset.Now < waitTill)
{
if (IsRunning != true)
if (!IsRunning)
return true;
Application.DoEvents();
Thread.Sleep(50);
@ -159,7 +158,7 @@ namespace SteamController.Helpers
if (configPath is null)
return null;
foreach (var line in File.ReadLines(configPath))
foreach (var line in File.ReadLines(configPath).Reverse())
{
var match = ControllerBlacklistRegex.Match(line);
if (!match.Success)
@ -208,7 +207,7 @@ namespace SteamController.Helpers
public static bool UpdateControllerBlacklist(ushort vendorId, ushort productId, bool add)
{
if (IsRunning == true)
if (IsRunning)
return false;
var configPath = SteamConfigPath;

View file

@ -47,7 +47,7 @@ namespace SteamController.Managers
private bool? UsesController()
{
if (!SteamConfiguration.IsRunning.GetValueOrDefault(false))
if (!SteamConfiguration.IsRunning)
return null;
return