1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-05 09:42:54 +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) foreach (var hitObject in hitObjects)
{ {
if (!(hitObject.HitWindows is HitWindows.EmptyHitWindows)) if (hitObject.HitWindows != HitWindows.Empty)
yield return hitObject; yield return hitObject;
foreach (HitObject nested in getAllApplicableHitObjects(hitObject.NestedHitObjects)) foreach (HitObject nested in getAllApplicableHitObjects(hitObject.NestedHitObjects))

View File

@ -65,6 +65,6 @@ namespace osu.Game.Rulesets.Scoring
return timeOffsets.Average(); 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"/>. /// 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). /// No time values are provided (meaning instantaneous hit or miss).
/// </summary> /// </summary>
public static HitWindows Empty => new EmptyHitWindows(); public static HitWindows Empty { get; } = new EmptyHitWindows();
public HitWindows() public HitWindows()
{ {
@ -182,7 +182,7 @@ namespace osu.Game.Rulesets.Scoring
/// </summary> /// </summary>
protected virtual DifficultyRange[] GetRanges() => base_ranges; protected virtual DifficultyRange[] GetRanges() => base_ranges;
public class EmptyHitWindows : HitWindows private class EmptyHitWindows : HitWindows
{ {
private static readonly DifficultyRange[] ranges = private static readonly DifficultyRange[] ranges =
{ {

View File

@ -45,7 +45,7 @@ namespace osu.Game.Screens.Play.HUD
} }
private bool changesUnstableRate(JudgementResult judgement) private bool changesUnstableRate(JudgementResult judgement)
=> !(judgement.HitObject.HitWindows is HitWindows.EmptyHitWindows) && judgement.IsHit; => judgement.HitObject.HitWindows != HitWindows.Empty && judgement.IsHit;
protected override void LoadComplete() 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> /// <param name="hitEvents">The <see cref="HitEvent"/>s to display the timing distribution of.</param>
public HitEventTimingDistributionGraph(IReadOnlyList<HitEvent> hitEvents) 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>>(); bins = Enumerable.Range(0, total_timing_distribution_bins).Select(_ => new Dictionary<HitResult, int>()).ToArray<IDictionary<HitResult, int>>();
} }