mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 14:46:38 +09:00
Reduce NestedHitObject
enumerator overhead
This was especially bad due to it allocating on any and every start time change, even the first (see usage in `HitObject.ctor`).
This commit is contained in:
@ -3,11 +3,12 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using JetBrains.Annotations;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.ListExtensions;
|
||||
using osu.Framework.Lists;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
@ -83,7 +84,7 @@ namespace osu.Game.Rulesets.Objects
|
||||
private readonly List<HitObject> nestedHitObjects = new List<HitObject>();
|
||||
|
||||
[JsonIgnore]
|
||||
public IReadOnlyList<HitObject> NestedHitObjects => nestedHitObjects;
|
||||
public SlimReadOnlyListWrapper<HitObject> NestedHitObjects => nestedHitObjects.AsSlimReadOnly();
|
||||
|
||||
public HitObject()
|
||||
{
|
||||
@ -91,7 +92,7 @@ namespace osu.Game.Rulesets.Objects
|
||||
{
|
||||
double offset = time.NewValue - time.OldValue;
|
||||
|
||||
foreach (var nested in NestedHitObjects)
|
||||
foreach (var nested in nestedHitObjects)
|
||||
nested.StartTime += offset;
|
||||
};
|
||||
}
|
||||
@ -122,11 +123,14 @@ namespace osu.Game.Rulesets.Objects
|
||||
|
||||
if (this is IHasComboInformation hasCombo)
|
||||
{
|
||||
foreach (var n in NestedHitObjects.OfType<IHasComboInformation>())
|
||||
foreach (HitObject hitObject in nestedHitObjects)
|
||||
{
|
||||
n.ComboIndexBindable.BindTo(hasCombo.ComboIndexBindable);
|
||||
n.ComboIndexWithOffsetsBindable.BindTo(hasCombo.ComboIndexWithOffsetsBindable);
|
||||
n.IndexInCurrentComboBindable.BindTo(hasCombo.IndexInCurrentComboBindable);
|
||||
if (hitObject is IHasComboInformation n)
|
||||
{
|
||||
n.ComboIndexBindable.BindTo(hasCombo.ComboIndexBindable);
|
||||
n.ComboIndexWithOffsetsBindable.BindTo(hasCombo.ComboIndexWithOffsetsBindable);
|
||||
n.IndexInCurrentComboBindable.BindTo(hasCombo.IndexInCurrentComboBindable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user