From 1fa0320845409380171b62570e5fd6e83045b26d Mon Sep 17 00:00:00 2001 From: wrenge Date: Wed, 13 Nov 2024 13:55:02 +0300 Subject: [PATCH] precache collections --- src/DotRecast.Detour.Crowd/DtCrowd.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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];