From 7dfac39408c62443e9103b393042c7abad39b838 Mon Sep 17 00:00:00 2001 From: Andrew Gilewsky Date: Tue, 5 Mar 2024 00:21:24 +0000 Subject: [PATCH] Optimization: reduce number of allocations on hot path. --- src/DotRecast.Recast/RcRasterizations.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DotRecast.Recast/RcRasterizations.cs b/src/DotRecast.Recast/RcRasterizations.cs index afa6a4e..9b1f638 100644 --- a/src/DotRecast.Recast/RcRasterizations.cs +++ b/src/DotRecast.Recast/RcRasterizations.cs @@ -156,7 +156,7 @@ namespace DotRecast.Recast float axisOffset, int axis) { // How far positive or negative away from the separating axis is each vertex. - float[] inVertAxisDelta = new float[12]; + Span inVertAxisDelta = stackalloc float[12]; for (int inVert = 0; inVert < inVertsCount; ++inVert) { inVertAxisDelta[inVert] = axisOffset - inVerts[inVertsOffset + inVert * 3 + axis];