1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 18:47:27 +08:00

Optimise mania density calculation during beatmap conversion

This commit is contained in:
Dan Balasescu 2023-06-15 20:00:15 +09:00
parent d563de0e54
commit 145530035c

View File

@ -119,14 +119,12 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
yield return obj;
}
private readonly List<double> prevNoteTimes = new List<double>(max_notes_for_density);
private readonly LimitedCapacityQueue<double> prevNoteTimes = new LimitedCapacityQueue<double>(max_notes_for_density);
private double density = int.MaxValue;
private void computeDensity(double newNoteTime)
{
if (prevNoteTimes.Count == max_notes_for_density)
prevNoteTimes.RemoveAt(0);
prevNoteTimes.Add(newNoteTime);
prevNoteTimes.Enqueue(newNoteTime);
if (prevNoteTimes.Count >= 2)
density = (prevNoteTimes[^1] - prevNoteTimes[0]) / prevNoteTimes.Count;