diff --git a/Minint.Core/Services/Impl/FloodFillService.cs b/Minint.Core/Services/Impl/FloodFillService.cs index 986b83f..22d85c5 100644 --- a/Minint.Core/Services/Impl/FloodFillService.cs +++ b/Minint.Core/Services/Impl/FloodFillService.cs @@ -16,15 +16,12 @@ public sealed class FloodFillService : IFloodFillService return; var queue = new Queue<(int X, int Y)>(); - var visited = new bool[width * height]; - queue.Enqueue((x, y)); - visited[y * width + x] = true; + pixels[y * width + x] = newColorIndex; while (queue.Count > 0) { var (cx, cy) = queue.Dequeue(); - pixels[cy * width + cx] = newColorIndex; Span<(int, int)> neighbors = [ @@ -37,9 +34,9 @@ public sealed class FloodFillService : IFloodFillService if (nx < 0 || nx >= width || ny < 0 || ny >= height) continue; int ni = ny * width + nx; - if (visited[ni] || pixels[ni] != targetIndex) + if (pixels[ni] != targetIndex) continue; - visited[ni] = true; + pixels[ni] = newColorIndex; queue.Enqueue((nx, ny)); } }