Skip to content

Commit 0be1862

Browse files
Merge pull request #299 from ARCoder181105/perf/optimize-stops-for-route-polyline-allocs
Optimize memory allocation in stops-for-route polyline generation
2 parents 307a56b + 3af227c commit 0be1862

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

internal/restapi/stops_for_route_handler.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,8 @@ func processTripGroups(
388388

389389
func generatePolylines(shapes []gtfsdb.GetShapesGroupedByTripHeadSignRow) []models.Polyline {
390390
var polylines []models.Polyline
391-
var coords [][]float64
391+
// This prevents repeated memory re-allocation during the loop.
392+
coords := make([][]float64, 0, len(shapes))
392393
for _, shape := range shapes {
393394
coords = append(coords, []float64{shape.Lat, shape.Lon})
394395
}

0 commit comments

Comments
 (0)