1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-05 03:03:21 +08:00

Make empty hitwindows readonly static and slightly improve comparison performance

This commit is contained in:
Dean Herbert 2024-11-25 19:17:32 +09:00
parent a1916d12db
commit 605fe71f46
No known key found for this signature in database
5 changed files with 6 additions and 6 deletions

View File

@ -205,7 +205,7 @@ namespace osu.Game.Rulesets.Mods
{
foreach (var hitObject in hitObjects)
{
if (!(hitObject.HitWindows is HitWindows.EmptyHitWindows))
if (hitObject.HitWindows != HitWindows.Empty)
yield return hitObject;
foreach (HitObject nested in getAllApplicableHitObjects(hitObject.NestedHitObjects))

View File

@ -65,6 +65,6 @@ namespace osu.Game.Rulesets.Scoring
return timeOffsets.Average();
}
public static bool AffectsUnstableRate(HitEvent e) => !(e.HitObject.HitWindows is HitWindows.EmptyHitWindows) && e.Result.IsHit();
public static bool AffectsUnstableRate(HitEvent e) => e.HitObject.HitWindows != HitWindows.Empty && e.Result.IsHit();
}
}

View File

@ -36,7 +36,7 @@ namespace osu.Game.Rulesets.Scoring
/// An empty <see cref="HitWindows"/> with only <see cref="HitResult.Miss"/> and <see cref="HitResult.Perfect"/>.
/// No time values are provided (meaning instantaneous hit or miss).
/// </summary>
public static HitWindows Empty => new EmptyHitWindows();
public static HitWindows Empty { get; } = new EmptyHitWindows();
public HitWindows()
{
@ -182,7 +182,7 @@ namespace osu.Game.Rulesets.Scoring
/// </summary>
protected virtual DifficultyRange[] GetRanges() => base_ranges;
public class EmptyHitWindows : HitWindows
private class EmptyHitWindows : HitWindows
{
private static readonly DifficultyRange[] ranges =
{

View File

@ -45,7 +45,7 @@ namespace osu.Game.Screens.Play.HUD
}
private bool changesUnstableRate(JudgementResult judgement)
=> !(judgement.HitObject.HitWindows is HitWindows.EmptyHitWindows) && judgement.IsHit;
=> judgement.HitObject.HitWindows != HitWindows.Empty && judgement.IsHit;
protected override void LoadComplete()
{

View File

@ -58,7 +58,7 @@ namespace osu.Game.Screens.Ranking.Statistics
/// <param name="hitEvents">The <see cref="HitEvent"/>s to display the timing distribution of.</param>
public HitEventTimingDistributionGraph(IReadOnlyList<HitEvent> hitEvents)
{
this.hitEvents = hitEvents.Where(e => !(e.HitObject.HitWindows is HitWindows.EmptyHitWindows) && e.Result.IsBasic() && e.Result.IsHit()).ToList();
this.hitEvents = hitEvents.Where(e => e.HitObject.HitWindows != HitWindows.Empty && e.Result.IsBasic() && e.Result.IsHit()).ToList();
bins = Enumerable.Range(0, total_timing_distribution_bins).Select(_ => new Dictionary<HitResult, int>()).ToArray<IDictionary<HitResult, int>>();
}