mirror of
https://github.com/ppy/osu.git
synced 2025-01-26 12:35:34 +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))
|
if (!(state is RulesetInputManagerInputState<T> inputState))
|
||||||
throw new InvalidOperationException($"{nameof(ReplayState<T>)} should only be applied to a {nameof(RulesetInputManagerInputState<T>)}");
|
throw new InvalidOperationException($"{nameof(ReplayState<T>)} should only be applied to a {nameof(RulesetInputManagerInputState<T>)}");
|
||||||
|
|
||||||
var lastPressed = inputState.LastReplayState?.PressedActions ?? new List<T>();
|
T[] released = Array.Empty<T>();
|
||||||
var released = lastPressed.Except(PressedActions).ToArray();
|
T[] pressed = Array.Empty<T>();
|
||||||
var pressed = PressedActions.Except(lastPressed).ToArray();
|
|
||||||
|
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;
|
inputState.LastReplayState = this;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user