Conversation
The generated pigeon code for `_deepEquals` uses a nested loop to compare Maps, resulting in O(N^2) complexity. This commit optimizes it by doing an O(1) `b.containsKey(keyA)` check first before falling back to the O(N) iteration for complex keys (like Lists or other Maps). This preserves the original behavior while significantly speeding up equality checks for typical Maps with primitive keys. Co-authored-by: esenmx <43244505+esenmx@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
💡 What: Replaced the O(N^2) Map deep equality check in
lib/src/messages.g.dart(generated by Pigeon) with an O(N) optimized version that uses a fast pathcontainsKeycheck first.🎯 Why: The previous implementation used a nested loop for all Maps, which is extremely inefficient (O(N^2)) for comparing Maps with many entries. Since most Map keys in Dart are primitives or have proper
hashCode/==implementations, we can try a fastb.containsKey(keyA)path first.📊 Measured Improvement:
(Note: While this file is generated by Pigeon, this patch fixes the generated Dart file directly per the task parameters. A long-term fix would involve upstreaming this change to the flutter/packages Pigeon repository.)
PR created automatically by Jules for task 16866471048232431032 started by @esenmx