From 57bc5ee04fd68fc317dea18c51d6d473f1eb80dd Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 3 Feb 2024 00:19:04 +0300 Subject: [PATCH] Improve readability --- osu.Game/Rulesets/Scoring/HitEventExtensions.cs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/osu.Game/Rulesets/Scoring/HitEventExtensions.cs b/osu.Game/Rulesets/Scoring/HitEventExtensions.cs index c3ad8980fe..ab36a54d3d 100644 --- a/osu.Game/Rulesets/Scoring/HitEventExtensions.cs +++ b/osu.Game/Rulesets/Scoring/HitEventExtensions.cs @@ -21,30 +21,28 @@ namespace osu.Game.Rulesets.Scoring { Debug.Assert(hitEvents.All(ev => ev.GameplayRate != null)); - double currentValue; - int k = 0; + int count = 0; double m = 0; double s = 0; - double mNext; foreach (var e in hitEvents) { if (!affectsUnstableRate(e)) continue; - // Division by gameplay rate is to account for TimeOffset scaling with gameplay rate. - currentValue = e.TimeOffset / e.GameplayRate!.Value; + count++; - k++; - mNext = m + (currentValue - m) / k; + // Division by gameplay rate is to account for TimeOffset scaling with gameplay rate. + double currentValue = e.TimeOffset / e.GameplayRate!.Value; + double mNext = m + (currentValue - m) / count; s += (currentValue - m) * (currentValue - mNext); m = mNext; } - if (k == 0) + if (count == 0) return null; - return 10.0 * Math.Sqrt(s / k); + return 10.0 * Math.Sqrt(s / count); } ///