From 7f4b12aca98e2719e883bce33ebc7705429e38c0 Mon Sep 17 00:00:00 2001 From: Masashi Katsumata Date: Sat, 21 Nov 2026 02:15:07 -0800 Subject: [PATCH] Read the antenna sample's state once when filtering The carrier filter read three @State values for each of 723,800 cells: 0.6 s on the main thread on an iPad Pro (Debug), 0.4 s in Release. They are read once now. --- .../Sources/pages/circle/AntennaHorizonsPage.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/samples/MapConductorSampleApp/Sources/pages/circle/AntennaHorizonsPage.swift b/samples/MapConductorSampleApp/Sources/pages/circle/AntennaHorizonsPage.swift index 1a3a4d6..7377ec7 100644 --- a/samples/MapConductorSampleApp/Sources/pages/circle/AntennaHorizonsPage.swift +++ b/samples/MapConductorSampleApp/Sources/pages/circle/AntennaHorizonsPage.swift @@ -182,7 +182,11 @@ struct AntennaHorizonsPage: View { tap = nil if carriers.count == carrierNames.count { circles = allCircles } else if carriers.isEmpty { circles = [] } - else { circles = allCircles.indices.compactMap { carriers.contains(rows[$0].carrier) ? allCircles[$0] : nil } } + else { + // Read each @State once: read in the loop, they cost 0.6 s over 723,800 cells on an iPad Pro. + let carriers = carriers, rows = rows, all = allCircles + circles = all.indices.compactMap { carriers.contains(rows[$0].carrier) ? all[$0] : nil } + } } private func moveCamera(_ lat: Double, _ lon: Double, _ zoom: Double) { let camera = MapCameraPosition(position: GeoPoint(latitude: lat, longitude: lon), zoom: zoom)