mirror of
https://github.com/ppy/osu.git
synced 2025-01-06 08:22:56 +08:00
Optimise mania density calculation during beatmap conversion
This commit is contained in:
parent
d563de0e54
commit
145530035c
@ -119,14 +119,12 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
|
|||||||
yield return obj;
|
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 double density = int.MaxValue;
|
||||||
|
|
||||||
private void computeDensity(double newNoteTime)
|
private void computeDensity(double newNoteTime)
|
||||||
{
|
{
|
||||||
if (prevNoteTimes.Count == max_notes_for_density)
|
prevNoteTimes.Enqueue(newNoteTime);
|
||||||
prevNoteTimes.RemoveAt(0);
|
|
||||||
prevNoteTimes.Add(newNoteTime);
|
|
||||||
|
|
||||||
if (prevNoteTimes.Count >= 2)
|
if (prevNoteTimes.Count >= 2)
|
||||||
density = (prevNoteTimes[^1] - prevNoteTimes[0]) / prevNoteTimes.Count;
|
density = (prevNoteTimes[^1] - prevNoteTimes[0]) / prevNoteTimes.Count;
|
||||||
|
Loading…
Reference in New Issue
Block a user