mirror of
https://github.com/ppy/osu.git
synced 2025-02-12 05:13:08 +08:00
The overhead of LINQ is not ignorable
This commit is contained in:
parent
bcb91f348d
commit
470d2be2e1
@ -302,7 +302,7 @@ namespace osu.Game.Rulesets.Objects.Legacy
|
||||
controlPoints.AddRange(convertPoints(segments[i].Type, new ArraySegment<Vector2>(points, startIndex, endIndex - startIndex), endPoint));
|
||||
}
|
||||
|
||||
return controlPoints.SelectMany(s => s).ToArray();
|
||||
return mergePointsLists(controlPoints);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -392,6 +392,25 @@ namespace osu.Game.Rulesets.Objects.Legacy
|
||||
- (p1.X - p0.X) * (p2.Y - p0.Y));
|
||||
}
|
||||
|
||||
private PathControlPoint[] mergePointsLists(List<ArraySegment<PathControlPoint>> controlPointList)
|
||||
{
|
||||
int totalCount = 0;
|
||||
|
||||
foreach (var arr in controlPointList)
|
||||
totalCount += arr.Count;
|
||||
|
||||
var mergedArray = new PathControlPoint[totalCount];
|
||||
int copyIndex = 0;
|
||||
|
||||
foreach (var arr in controlPointList)
|
||||
{
|
||||
arr.AsSpan().CopyTo(mergedArray.AsSpan(copyIndex));
|
||||
copyIndex += arr.Count;
|
||||
}
|
||||
|
||||
return mergedArray;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a legacy Hit-type hit object.
|
||||
/// </summary>
|
||||
|
Loading…
Reference in New Issue
Block a user