MergeCorridorStartShortcut alloc fix

This commit is contained in:
wrenge 2024-11-13 12:52:33 +03:00
parent 4dee6b20b5
commit 05613f196f
1 changed files with 7 additions and 4 deletions

View File

@ -276,12 +276,15 @@ namespace DotRecast.Detour
// Concatenate paths. // Concatenate paths.
// Adjust beginning of the buffer to include the visited. // Adjust beginning of the buffer to include the visited.
List<long> result = visited.GetRange(0, furthestVisited); var length1 = furthestVisited;
result.AddRange(path.GetRange(furthestPath, npath - furthestPath)); var length2 = npath - furthestPath;
using var result = RcRentedArray.Rent<long>(length1 + length2);
visited.CopyTo(0, result.AsArray(), 0, length1);
path.CopyTo(furthestPath, result.AsArray(), length1, length2);
path.Clear(); path.Clear();
path.AddRange(result); CollectionExtensions.AddRange(path, result.AsSpan());
return result.Count; return result.Length;
} }
} }
} }