diff --git a/src/DotRecast.Core/Buffers/RcRentedArray.cs b/src/DotRecast.Core/Buffers/RcRentedArray.cs index 68f12c7..208b951 100644 --- a/src/DotRecast.Core/Buffers/RcRentedArray.cs +++ b/src/DotRecast.Core/Buffers/RcRentedArray.cs @@ -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 AsSpan() + { + return new Span(_array, 0, Length); + } + public void Dispose() { diff --git a/src/DotRecast.Detour/DtNavMeshQuery.cs b/src/DotRecast.Detour/DtNavMeshQuery.cs index faeb460..e927024 100644 --- a/src/DotRecast.Detour/DtNavMeshQuery.cs +++ b/src/DotRecast.Detour/DtNavMeshQuery.cs @@ -599,7 +599,7 @@ namespace DotRecast.Detour const int batchSize = 32; Span polyRefs = stackalloc long[batchSize]; using RcRentedArray polysRent = RcRentedArray.Rent(batchSize); - Span polys = new Span(polysRent.AsArray(), 0, batchSize); + Span polys = polysRent.AsSpan(); int n = 0; if (tile.data.bvTree != null)