perf: Array/Dictionary Improvement

This commit is contained in:
Syntriax 2024-01-22 23:30:21 +03:00
parent 388e7f4788
commit de10a859ae
1 changed files with 4 additions and 4 deletions

View File

@ -7,14 +7,14 @@ namespace Syntriax.Engine.Input;
public class KeyboardInputsBehaviour : BehaviourOverride, IKeyboardInputs public class KeyboardInputsBehaviour : BehaviourOverride, IKeyboardInputs
{ {
private IDictionary<Keys, Action<IKeyboardInputs, Keys>> OnPressed = new Dictionary<Keys, Action<IKeyboardInputs, Keys>>(256); private readonly Dictionary<Keys, Action<IKeyboardInputs, Keys>> OnPressed = new(256);
private IDictionary<Keys, Action<IKeyboardInputs, Keys>> OnReleased = new Dictionary<Keys, Action<IKeyboardInputs, Keys>>(256); private readonly Dictionary<Keys, Action<IKeyboardInputs, Keys>> OnReleased = new(256);
private int cachePressedCurrentlyCount = 0; private int cachePressedCurrentlyCount = 0;
private Keys[] cachePressedCurrently = new Keys[256]; private readonly Keys[] cachePressedCurrently = new Keys[256];
private int cachePressedPreviouslyCount = 0; private int cachePressedPreviouslyCount = 0;
private Keys[] cachePressedPreviously = new Keys[256]; private readonly Keys[] cachePressedPreviously = new Keys[256];
public void RegisterOnPress(Keys key, Action<IKeyboardInputs, Keys> callback) public void RegisterOnPress(Keys key, Action<IKeyboardInputs, Keys> callback)
{ {