Merge pull request #10208 from peppy/reduce-all-hitobject-enumerator-complexity

Reduce complexity of AllHitObjects enumerator when nested playfields are not present
This commit is contained in:
Dan Balasescu 2020-09-23 11:50:10 +09:00 committed by GitHub
commit 6d58973452
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -37,7 +37,21 @@ namespace osu.Game.Rulesets.UI
/// <summary>
/// All the <see cref="DrawableHitObject"/>s contained in this <see cref="Playfield"/> and all <see cref="NestedPlayfields"/>.
/// </summary>
public IEnumerable<DrawableHitObject> AllHitObjects => HitObjectContainer?.Objects.Concat(NestedPlayfields.SelectMany(p => p.AllHitObjects)) ?? Enumerable.Empty<DrawableHitObject>();
public IEnumerable<DrawableHitObject> AllHitObjects
{
get
{
if (HitObjectContainer == null)
return Enumerable.Empty<DrawableHitObject>();
var enumerable = HitObjectContainer.Objects;
if (nestedPlayfields.IsValueCreated)
enumerable = enumerable.Concat(NestedPlayfields.SelectMany(p => p.AllHitObjects));
return enumerable;
}
}
/// <summary>
/// All <see cref="Playfield"/>s nested inside this <see cref="Playfield"/>.