Span access

This commit is contained in:
wrenge 2024-11-11 14:26:35 +03:00
parent c8104cec4d
commit 6fe6844efd
2 changed files with 7 additions and 2 deletions

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Buffers;
using System.Runtime.CompilerServices;
@ -43,6 +43,11 @@ namespace DotRecast.Core.Buffers
return _array;
}
public Span<T> AsSpan()
{
return new Span<T>(_array, 0, Length);
}
public void Dispose()
{

View File

@ -599,7 +599,7 @@ namespace DotRecast.Detour
const int batchSize = 32;
Span<long> polyRefs = stackalloc long[batchSize];
using RcRentedArray<DtPoly> polysRent = RcRentedArray.Rent<DtPoly>(batchSize);
Span<DtPoly> polys = new Span<DtPoly>(polysRent.AsArray(), 0, batchSize);
Span<DtPoly> polys = polysRent.AsSpan();
int n = 0;
if (tile.data.bvTree != null)