Skip to content

Commit

Permalink
use HashSet instead of Dictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
Valkirie committed Nov 23, 2023
1 parent 8d1ec42 commit 2b13caa
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions HandheldCompanion/Managers/ControllerManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ private static void Watchdog_Elapsed(object? sender, ElapsedEventArgs e)
lock (updateLock)
{
// monitoring unexpected slot changes
Dictionary<byte, bool> UserIndexes = new();
HashSet<byte> UserIndexes = new();
bool XInputDrunk = false;
foreach (XInputController xInputController in Controllers.Values.Where(c => c.Details is not null && c.Details.isXInput))
{
Expand All @@ -576,10 +576,9 @@ private static void Watchdog_Elapsed(object? sender, ElapsedEventArgs e)
continue;

// that's not possible, XInput is drunk
if (UserIndexes.ContainsKey(UserIndex))
if (!UserIndexes.Add(UserIndex))
XInputDrunk = true;

UserIndexes.Add(UserIndex, true);
xInputController.AttachController(UserIndex);
}

Expand Down

0 comments on commit 2b13caa

Please sign in to comment.