forked from mirror/DotRecast
MergeCorridorEndMoved alloc fix
This commit is contained in:
parent
05613f196f
commit
418a39a576
|
@ -231,15 +231,15 @@ namespace DotRecast.Detour
|
||||||
}
|
}
|
||||||
|
|
||||||
// Concatenate paths.
|
// Concatenate paths.
|
||||||
List<long> result = path.GetRange(0, furthestPath);
|
var length1 = furthestPath;
|
||||||
foreach (var v in visited.Slice(furthestVisited, nvisited - furthestVisited))
|
var length2 = nvisited - furthestVisited;
|
||||||
{
|
using var result = RcRentedArray.Rent<long>(length1 + length2);
|
||||||
result.Add(v);
|
path.CopyTo(0, result.AsArray(), 0, length1);
|
||||||
}
|
visited.Slice(furthestVisited, nvisited - furthestVisited).CopyTo(result.AsSpan().Slice(length1, length2));
|
||||||
|
|
||||||
path.Clear();
|
path.Clear();
|
||||||
path.AddRange(result);
|
CollectionExtensions.AddRange(path, result.AsSpan());
|
||||||
return result.Count;
|
return path.Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int MergeCorridorStartShortcut(List<long> path, int npath, int maxPath, List<long> visited, int nvisited)
|
public static int MergeCorridorStartShortcut(List<long> path, int npath, int maxPath, List<long> visited, int nvisited)
|
||||||
|
@ -284,7 +284,7 @@ namespace DotRecast.Detour
|
||||||
|
|
||||||
path.Clear();
|
path.Clear();
|
||||||
CollectionExtensions.AddRange(path, result.AsSpan());
|
CollectionExtensions.AddRange(path, result.AsSpan());
|
||||||
return result.Length;
|
return path.Count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue