Found faster way to iterate over a ValueCollection

This commit is contained in:
Travis Nickles 2019-02-16 02:16:56 -06:00
parent 50109282f4
commit cd6742cf56

View File

@ -40,9 +40,11 @@ namespace DS4Windows
//foreach (KeyPresses kp in keyPresses.Values) //foreach (KeyPresses kp in keyPresses.Values)
Dictionary<ushort, KeyPresses>.ValueCollection keyValues = keyPresses.Values; Dictionary<ushort, KeyPresses>.ValueCollection keyValues = keyPresses.Values;
for (int i = 0, kpCount = keyValues.Count; i < kpCount; i++) for (var keyEnum = keyValues.GetEnumerator(); keyEnum.MoveNext();)
//for (int i = 0, kpCount = keyValues.Count; i < kpCount; i++)
{ {
KeyPresses kp = keyValues.ElementAt(i); //KeyPresses kp = keyValues.ElementAt(i);
KeyPresses kp = keyEnum.Current;
kp.previous = kp.current; kp.previous = kp.current;
if (performClear) if (performClear)
{ {