1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 20:07:25 +08:00

Merge pull request #27297 from EVAST9919/timeline-alloc

Reduce allocations in `TimelineBlueprintContainer`
This commit is contained in:
Dean Herbert 2024-02-22 09:16:16 +08:00 committed by GitHub
commit d82b398752
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -116,6 +116,8 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
updateStacking();
}
private readonly Stack<HitObject> currentConcurrentObjects = new Stack<HitObject>();
private void updateStacking()
{
// because only blueprints of objects which are alive (via pooling) are displayed in the timeline, it's feasible to do this every-update.
@ -125,10 +127,12 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
// after the stack gets this tall, we can presume there is space underneath to draw subsequent blueprints.
const int stack_reset_count = 3;
Stack<HitObject> currentConcurrentObjects = new Stack<HitObject>();
currentConcurrentObjects.Clear();
foreach (var b in SelectionBlueprints.Reverse())
for (int i = SelectionBlueprints.Count - 1; i >= 0; i--)
{
var b = SelectionBlueprints[i];
// remove objects from the stack as long as their end time is in the past.
while (currentConcurrentObjects.TryPeek(out HitObject hitObject))
{