mirror of https://github.com/ppy/osu
Reduce allocation in Playfield
This commit is contained in:
parent
7cdedfb6ca
commit
53c5483eba
|
@ -247,10 +247,14 @@ protected void AddNested(Playfield otherPlayfield)
|
|||
nestedPlayfields.Add(otherPlayfield);
|
||||
}
|
||||
|
||||
private Mod[] mods;
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
mods = Mods?.ToArray();
|
||||
|
||||
// in the case a consumer forgets to add the HitObjectContainer, we will add it here.
|
||||
if (HitObjectContainer.Parent == null)
|
||||
AddInternal(HitObjectContainer);
|
||||
|
@ -260,9 +264,9 @@ protected override void Update()
|
|||
{
|
||||
base.Update();
|
||||
|
||||
if (!IsNested && Mods != null)
|
||||
if (!IsNested && mods != null)
|
||||
{
|
||||
foreach (var mod in Mods)
|
||||
foreach (Mod mod in mods)
|
||||
{
|
||||
if (mod is IUpdatableByPlayfield updatable)
|
||||
updatable.Update(this);
|
||||
|
@ -403,10 +407,13 @@ DrawableHitObject IPooledHitObjectProvider.GetPooledDrawableRepresentation(HitOb
|
|||
|
||||
// If this is the first time this DHO is being used, then apply the DHO mods.
|
||||
// This is done before Apply() so that the state is updated once when the hitobject is applied.
|
||||
if (Mods != null)
|
||||
if (mods != null)
|
||||
{
|
||||
foreach (var m in Mods.OfType<IApplicableToDrawableHitObject>())
|
||||
m.ApplyToDrawableHitObject(dho);
|
||||
foreach (Mod mod in mods)
|
||||
{
|
||||
if (mod is IApplicableToDrawableHitObject applicable)
|
||||
applicable.ApplyToDrawableHitObject(dho);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue