Skip to content

Commit 9a4c795

Browse files
authored
Merge pull request ppy#6368 from peppy/fix-pressed-keys-allocs
Fix alloc overhead in hot path for keyboard checks
2 parents c5bfbcb + fa9bd17 commit 9a4c795

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

osu.Framework/Input/Bindings/KeyCombination.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,14 @@ internal static bool IsPressed(ImmutableArray<InputKey> pressedPhysicalKeys, Inp
207207
return pressedPhysicalKeys.Contains(candidateKey);
208208

209209
Debug.Assert(candidateKey.IsVirtual());
210-
return pressedPhysicalKeys.Any(k => getVirtualKey(k) == candidateKey);
210+
211+
foreach (var pk in pressedPhysicalKeys)
212+
{
213+
if (getVirtualKey(pk) == candidateKey)
214+
return true;
215+
}
216+
217+
return false;
211218
}
212219

213220
public bool Equals(KeyCombination other) => Keys.SequenceEqual(other.Keys);

0 commit comments

Comments
 (0)