mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 11:42:54 +08:00
Avoid unnecessary array/LINQ operations when replay frames have no action changes
This commit is contained in:
parent
f02b6b3657
commit
f4199958d9
@ -42,9 +42,24 @@ namespace osu.Game.Input.Handlers
|
||||
if (!(state is RulesetInputManagerInputState<T> inputState))
|
||||
throw new InvalidOperationException($"{nameof(ReplayState<T>)} should only be applied to a {nameof(RulesetInputManagerInputState<T>)}");
|
||||
|
||||
var lastPressed = inputState.LastReplayState?.PressedActions ?? new List<T>();
|
||||
var released = lastPressed.Except(PressedActions).ToArray();
|
||||
var pressed = PressedActions.Except(lastPressed).ToArray();
|
||||
T[] released = Array.Empty<T>();
|
||||
T[] pressed = Array.Empty<T>();
|
||||
|
||||
var lastPressed = inputState.LastReplayState?.PressedActions;
|
||||
|
||||
if (lastPressed == null || lastPressed.Count == 0)
|
||||
{
|
||||
pressed = PressedActions.ToArray();
|
||||
}
|
||||
else if (PressedActions.Count == 0)
|
||||
{
|
||||
released = lastPressed.ToArray();
|
||||
}
|
||||
else if (!lastPressed.SequenceEqual(PressedActions))
|
||||
{
|
||||
released = lastPressed.Except(PressedActions).ToArray();
|
||||
pressed = PressedActions.Except(lastPressed).ToArray();
|
||||
}
|
||||
|
||||
inputState.LastReplayState = this;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user