From 83bb3dc2f38c7b9a2ae2d88df084fa674065da52 Mon Sep 17 00:00:00 2001 From: Stone_Red <56473591+Stone-Red-Code@users.noreply.github.com> Date: Tue, 5 May 2026 23:22:25 +0200 Subject: [PATCH] Add comment explaining candidate skipping tradeoff in grid filling --- src/LargeGridPathfinding/GridFiller.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/LargeGridPathfinding/GridFiller.cs b/src/LargeGridPathfinding/GridFiller.cs index 0fee7ad..e2cb58d 100644 --- a/src/LargeGridPathfinding/GridFiller.cs +++ b/src/LargeGridPathfinding/GridFiller.cs @@ -90,6 +90,12 @@ public class GridFiller if (w > 0 && h > 0) { candidates.Add((x, y, w, h, tileWeight)); + + // This does technically create some inefficiency by skipping some potential candidates, + // but it drastically reduces the number of candidates and thus speeds up the overall process. + // Using x += 1 here instead would be the semantically correct way to find all candidates. + // The tradeoff is either slower filling with more candidates or faster filling with fewer candidates. + // Fewer candidates lead to better pathfinding performance. x += Math.Max(1, Math.Min(w, h)); } else