1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 10:33:30 +08:00

replace linq usage in Previous and Next with more direct computation

This commit is contained in:
tsunyoku 2024-02-10 15:42:55 +00:00
parent 4b847b68a2
commit 901b82384d

View File

@ -4,7 +4,6 @@
#nullable disable
using System.Collections.Generic;
using System.Linq;
using osu.Game.Rulesets.Objects;
namespace osu.Game.Rulesets.Difficulty.Preprocessing
@ -65,8 +64,16 @@ namespace osu.Game.Rulesets.Difficulty.Preprocessing
EndTime = hitObject.GetEndTime() / clockRate;
}
public DifficultyHitObject Previous(int backwardsIndex) => difficultyHitObjects.ElementAtOrDefault(Index - (backwardsIndex + 1));
public DifficultyHitObject Previous(int backwardsIndex)
{
int index = Index - (backwardsIndex + 1);
return index >= 0 && index < difficultyHitObjects.Count ? difficultyHitObjects[index] : default;
}
public DifficultyHitObject Next(int forwardsIndex) => difficultyHitObjects.ElementAtOrDefault(Index + (forwardsIndex + 1));
public DifficultyHitObject Next(int forwardsIndex)
{
int index = Index + (forwardsIndex + 1);
return index >= 0 && index < difficultyHitObjects.Count ? difficultyHitObjects[index] : default;
}
}
}