[ENHANCEMENT] GridMapGenerator: LINQ allocations in A* generation loop #29

Open
opened 2026-03-12 00:04:05 +00:00 by lavarius · 0 comments
Owner

🟢 Low — Design Enhancement

File: GridMapGenerator.cs

LINQ chains (.Where().OrderBy().Take()) are used inside the A* generation loop, allocating managed memory on every iteration. This causes GC pressure during map generation.

Fix:

  • Cache .Where() results where the filter doesn't change per iteration
  • Replace .OrderBy().Take(1) with a manual min-search loop (no allocation)
  • Or use pre-sorted data structures (e.g. SortedList, priority queue) to avoid per-step sorting
## 🟢 Low — Design Enhancement **File:** `GridMapGenerator.cs` LINQ chains (`.Where().OrderBy().Take()`) are used inside the A* generation loop, allocating managed memory on every iteration. This causes GC pressure during map generation. **Fix:** - Cache `.Where()` results where the filter doesn't change per iteration - Replace `.OrderBy().Take(1)` with a manual min-search loop (no allocation) - Or use pre-sorted data structures (e.g. `SortedList`, priority queue) to avoid per-step sorting
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lavarius/ProjectOverlay#29
No description provided.