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:
Dean Herbert
2021-09-20 01:48:33 +09:00
parent 0d58530dbe
commit 16e60eed56
2 changed files with 12 additions and 8 deletions

View File

@ -52,7 +52,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty
// In 2B beatmaps, it is possible that a normal Fruit is placed in the middle of a JuiceStream.
foreach (var hitObject in beatmap.HitObjects
.SelectMany(obj => obj is JuiceStream stream ? stream.NestedHitObjects : new[] { obj })
.SelectMany(obj => obj is JuiceStream stream ? stream.NestedHitObjects.AsEnumerable() : new[] { obj })
.Cast<CatchHitObject>()
.OrderBy(x => x.StartTime))
{