From 778dfa701d8038d2fe0a43a141d39da7aa2abcf4 Mon Sep 17 00:00:00 2001 From: nathen Date: Wed, 24 Jan 2024 18:08:34 -0500 Subject: [PATCH] Slightly improve linq expressions --- osu.Game.Rulesets.Osu/Statistics/AimError.cs | 4 ++-- osu.Game.Rulesets.Osu/Statistics/AverageAimError.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Statistics/AimError.cs b/osu.Game.Rulesets.Osu/Statistics/AimError.cs index 3ac868a616..a7a5b4508d 100644 --- a/osu.Game.Rulesets.Osu/Statistics/AimError.cs +++ b/osu.Game.Rulesets.Osu/Statistics/AimError.cs @@ -33,7 +33,7 @@ namespace osu.Game.Rulesets.Osu.Statistics private double? calculateAimError(IEnumerable hitEvents, IBeatmap playableBeatmap) { - IEnumerable hitCircleEvents = hitEvents.Where(e => e.HitObject is HitCircle && !(e.HitObject is SliderTailCircle)); + IEnumerable hitCircleEvents = hitEvents.Where(e => e.HitObject is HitCircle && !(e.HitObject is SliderTailCircle)).ToList(); double nonMissCount = hitCircleEvents.Count(e => e.Result.IsHit()); double missCount = hitCircleEvents.Count() - nonMissCount; @@ -54,7 +54,7 @@ namespace osu.Game.Rulesets.Osu.Statistics // We don't get data for miss locations, so we estimate the total variance using the Rayleigh distribution. // Deriving the Rayleigh distribution in this form results in a 2 in the denominator, // but it is removed to take the variance across both axes, instead of across just one. - double variance = (missCount * Math.Pow(radius, 2) + hitPoints.Aggregate(0.0, (current, point) => current + point.LengthSquared)) / nonMissCount; + double variance = (missCount * Math.Pow(radius, 2) + hitPoints.Sum(point => point.LengthSquared)) / nonMissCount; return Math.Sqrt(variance) * 10; } diff --git a/osu.Game.Rulesets.Osu/Statistics/AverageAimError.cs b/osu.Game.Rulesets.Osu/Statistics/AverageAimError.cs index 52bef8e0fd..fe0fe18211 100644 --- a/osu.Game.Rulesets.Osu/Statistics/AverageAimError.cs +++ b/osu.Game.Rulesets.Osu/Statistics/AverageAimError.cs @@ -30,7 +30,7 @@ namespace osu.Game.Rulesets.Osu.Statistics private double? calculateAverageAimError(IEnumerable hitEvents) { - IEnumerable hitCircleEvents = hitEvents.Where(e => e.HitObject is HitCircle && !(e.HitObject is SliderTailCircle) && e.Result.IsHit()); + IEnumerable hitCircleEvents = hitEvents.Where(e => e.HitObject is HitCircle && !(e.HitObject is SliderTailCircle) && e.Result.IsHit()).ToList(); double nonMissCount = hitCircleEvents.Count(e => e.Result.IsHit());