1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 09:58:21 +08:00

Merge pull request #10212 from peppy/fix-follow-point-connection-churn

Fix large construction/disposal overhead on beatmaps with hitobjects at same point in time
This commit is contained in:
Dan Balasescu 2020-09-23 19:46:38 +09:00 committed by GitHub
commit 6b8d7afdff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -46,7 +46,20 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
private void addConnection(FollowPointConnection connection)
{
// Groups are sorted by their start time when added such that the index can be used to post-process other surrounding connections
int index = connections.AddInPlace(connection, Comparer<FollowPointConnection>.Create((g1, g2) => g1.StartTime.Value.CompareTo(g2.StartTime.Value)));
int index = connections.AddInPlace(connection, Comparer<FollowPointConnection>.Create((g1, g2) =>
{
int comp = g1.StartTime.Value.CompareTo(g2.StartTime.Value);
if (comp != 0)
return comp;
// we always want to insert the new item after equal ones.
// this is important for beatmaps with multiple hitobjects at the same point in time.
// if we use standard comparison insert order, there will be a churn of connections getting re-updated to
// the next object at the point-in-time, adding a construction/disposal overhead (see FollowPointConnection.End implementation's ClearInternal).
// this is easily visible on https://osu.ppy.sh/beatmapsets/150945#osu/372245
return -1;
}));
if (index < connections.Count - 1)
{