From 8075ca113c2fb437a1a5280d73bf8a1ccfba23d0 Mon Sep 17 00:00:00 2001 From: Roman Pytkov Date: Fri, 10 Apr 2026 01:11:24 +0300 Subject: [PATCH] =?UTF-8?q?=D1=83=D0=BB=D1=83=D1=87=D1=88=D0=B5=D0=BD=20?= =?UTF-8?q?=D0=B0=D0=BB=D0=B3=D0=BE=D1=80=D0=B8=D1=82=D0=BC=20=D0=B7=D0=B0?= =?UTF-8?q?=D0=BB=D0=B8=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Minint.Core/Services/Impl/FloodFillService.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) 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)); } }