Use rented array instead of allocating

(cherry picked from commit ff930712ee)
This commit is contained in:
wrenge 2024-11-12 11:18:14 +03:00 committed by wrenge
parent 7aeb31d369
commit a7b9b772c4
2 changed files with 7 additions and 1 deletions

View File

@ -1365,6 +1365,11 @@ namespace DotRecast.Detour
}
public int GetTilesAt(int x, int y, DtMeshTile[] tiles, int maxTiles)
{
return GetTilesAt(x, y, (Span<DtMeshTile>)tiles, maxTiles);
}
public int GetTilesAt(int x, int y, Span<DtMeshTile> tiles, int maxTiles)
{
int n = 0;

View File

@ -797,7 +797,8 @@ namespace DotRecast.Detour
m_nav.CalcTileLoc(bmax, out var maxx, out var maxy);
const int MAX_NEIS = 32;
DtMeshTile[] neis = new DtMeshTile[MAX_NEIS];
using RcRentedArray<DtMeshTile> neisRent = RcRentedArray.Rent<DtMeshTile>(MAX_NEIS);
Span<DtMeshTile> neis = neisRent.AsSpan();
for (int y = miny; y <= maxy; ++y)
{