diff --git a/src/DotRecast.Detour.Crowd/DtCrowd.cs b/src/DotRecast.Detour.Crowd/DtCrowd.cs index c005424..d148a86 100644 --- a/src/DotRecast.Detour.Crowd/DtCrowd.cs +++ b/src/DotRecast.Detour.Crowd/DtCrowd.cs @@ -565,14 +565,18 @@ namespace DotRecast.Detour.Crowd } } + private readonly RcSortedQueue UpdateMoveRequest_queue = new RcSortedQueue((a1, a2) => a2.targetReplanTime.CompareTo(a1.targetReplanTime)); + private readonly List UpdateMoveRequest_reqPath = new List(); private void UpdateMoveRequest(IList agents, float dt) { using var timer = _telemetry.ScopedTimer(DtCrowdTimerLabel.UpdateMoveRequest); - RcSortedQueue queue = new RcSortedQueue((a1, a2) => a2.targetReplanTime.CompareTo(a1.targetReplanTime)); + RcSortedQueue queue = UpdateMoveRequest_queue; + queue.Clear(); // Fire off new requests. - List reqPath = new List(); + List reqPath = UpdateMoveRequest_reqPath; + reqPath.Clear(); for (var i = 0; i < agents.Count; i++) { var ag = agents[i];