diff --git a/PathingAPI/Controllers/PPatherController.cs b/PathingAPI/Controllers/PPatherController.cs index d44e4726..67e45e70 100644 --- a/PathingAPI/Controllers/PPatherController.cs +++ b/PathingAPI/Controllers/PPatherController.cs @@ -10,6 +10,7 @@ using SharedLib.Data; using System; +using System.Buffers; using System.Collections.Generic; using System.Numerics; using System.Text.Json; @@ -70,12 +71,16 @@ public JsonResult MapRoute(int uimap1, float x1, float y1, int uimap2, float x2, service.Save(); + ArrayPool pool = ArrayPool.Shared; + var array = pool.Rent(path.locations.Count); + for (int i = 0; i < path.locations.Count; i++) { - path.locations[i] = service.ToLocal(path.locations[i], (int)service.SearchFrom.W, uimap1); + array[i] = service.ToLocal(path.locations[i], (int)service.SearchFrom.W, uimap1); } - return new JsonResult(path.locations, options); + pool.Return(array); + return new JsonResult(new ArraySegment(array, 0, path.locations.Count), options); } ///