From 7a864fa168f9c91acb0674d89c5f0f39f2b05650 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 1 Jul 2026 14:41:23 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20Replace=20O(N^2)=20dictionary=20dee?= =?UTF-8?q?p=20equality=20check=20with=20O(N)=20lookup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The generated code for deep equality of dictionaries loops over all values of `rhsDictionary` for each key in `lhsDictionary`, causing an O(N^2) time complexity. By looking up the value using `rhsDictionary[lhsKey]`, this drops to O(N). Co-authored-by: esenmx <43244505+esenmx@users.noreply.github.com> --- .../Sources/mapkit_flutter/messages.g.swift | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/darwin/mapkit_flutter/Sources/mapkit_flutter/messages.g.swift b/darwin/mapkit_flutter/Sources/mapkit_flutter/messages.g.swift index 7bbf549..f4066df 100644 --- a/darwin/mapkit_flutter/Sources/mapkit_flutter/messages.g.swift +++ b/darwin/mapkit_flutter/Sources/mapkit_flutter/messages.g.swift @@ -121,18 +121,13 @@ enum messagesPigeonInternal { case (let lhsDictionary, let rhsDictionary) as ([AnyHashable: Any?], [AnyHashable: Any?]): guard lhsDictionary.count == rhsDictionary.count else { return false } for (lhsKey, lhsValue) in lhsDictionary { - var found = false - for (rhsKey, rhsValue) in rhsDictionary { - if deepEquals(lhsKey, rhsKey) { - if deepEquals(lhsValue, rhsValue) { - found = true - break - } else { - return false - } + if let rhsValue = rhsDictionary[lhsKey] { + if !deepEquals(lhsValue, rhsValue) { + return false } + } else { + return false } - if !found { return false } } return true