Optimization: reduce number of allocations on hot path.

This commit is contained in:
Andrew Gilewsky 2024-03-05 00:21:24 +00:00 committed by Ikpil
parent 4b8cd8e31b
commit 7dfac39408
1 changed files with 1 additions and 1 deletions

View File

@ -156,7 +156,7 @@ namespace DotRecast.Recast
float axisOffset, int axis) float axisOffset, int axis)
{ {
// How far positive or negative away from the separating axis is each vertex. // How far positive or negative away from the separating axis is each vertex.
float[] inVertAxisDelta = new float[12]; Span<float> inVertAxisDelta = stackalloc float[12];
for (int inVert = 0; inVert < inVertsCount; ++inVert) for (int inVert = 0; inVert < inVertsCount; ++inVert)
{ {
inVertAxisDelta[inVert] = axisOffset - inVerts[inVertsOffset + inVert * 3 + axis]; inVertAxisDelta[inVert] = axisOffset - inVerts[inVertsOffset + inVert * 3 + axis];