Use rented array instead of allocating

This commit is contained in:
wrenge 2024-11-12 11:18:14 +03:00
parent 6fe6844efd
commit ff930712ee
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) 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; int n = 0;

View File

@ -788,7 +788,8 @@ namespace DotRecast.Detour
m_nav.CalcTileLoc(bmax, out var maxx, out var maxy); m_nav.CalcTileLoc(bmax, out var maxx, out var maxy);
const int MAX_NEIS = 32; 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) for (int y = miny; y <= maxy; ++y)
{ {