Skip to content

[pigeon] Optimize data class equality and hashing in Dart, Kotlin, java, and Swift, adds equality in other languages - #11140

Merged
auto-submit[bot] merged 44 commits into
flutter:mainfrom
tarrinneal:effic
Mar 25, 2026
Merged

auto-submit[bot] merged 44 commits into
flutter:mainfrom
tarrinneal:effic

Conversation

@tarrinneal

@tarrinneal tarrinneal commented Feb 28, 2026 •

Copy link
Copy Markdown
Contributor

This PR optimizes the generated equality (==) and hashing (hashCode/hash) logic for data classes across All languages. These have been bothering me for a while, and I wanted to break out a new pr before the NI code is in review.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces significant performance optimizations for data class equality and hashing in Dart, Kotlin, and Swift by avoiding the creation of intermediate lists. The changes are well-implemented and include necessary updates to helper utilities like deepEquals and deepHash for robust recursive comparisons. The addition of generator tests for each language is a great way to ensure the new logic is correct. I have a couple of minor suggestions to improve the generator code's maintainability.

@tarrinneal tarrinneal changed the title [pigeon] Optimize data class equality and hashing in Dart, Kotlin, and Swift [pigeon] Optimize data class equality and hashing in Dart, Kotlin, and Swift, adds equality in other languages Mar 4, 2026
@tarrinneal

Copy link
Copy Markdown
Contributor Author

/gemini review

@tarrinneal

Copy link
Copy Markdown
Contributor Author

@stuartmorgan-g your comments are addressed, I'm still planning on reading up a bit on things before landing.

@stuartmorgan-g stuartmorgan-g left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor notes (mostly orthodontia), but otherwise LGTM.

return pigeonDeepEquals(name, that.name)
&& pigeonDeepEquals(description, that.description)
&& pigeonDeepEquals(code, that.code)
&& pigeonDeepEquals(data, that.data);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't actually, any non-collections well return first before any type checking.

I'm not following. The first line in this statement is calling pigeonDeepEquals with two strings. We know at compile time they are strings. But we are calling pigeonDeepEquals for them which will do runtime checks for whether they are:

  • byte arrays
  • int arrays
  • long arrays
  • double arrays
  • Lists
  • Maps
  • Doubles
  • Floats

and only then, after all of that, check that the strings are equal.

Comment thread packages/pigeon/platform_tests/test_plugin/windows/CMakeLists.txt
Comment thread packages/pigeon/example/app/linux/messages.g.cc Outdated
Comment thread packages/pigeon/example/app/linux/messages.g.cc
Comment thread packages/pigeon/example/app/linux/messages.g.cc Outdated
Comment thread packages/pigeon/example/app/windows/runner/messages.g.cpp Outdated
Comment thread packages/pigeon/example/app/windows/runner/messages.g.cpp
Comment thread packages/pigeon/example/app/windows/runner/messages.g.cpp Outdated
Comment thread packages/pigeon/example/app/windows/runner/messages.g.cpp Outdated
@tarrinneal

Copy link
Copy Markdown
Contributor Author

(mostly orthodontia)

Can we add a gobject lint tool?

@tarrinneal

Copy link
Copy Markdown
Contributor Author

@stuartmorgan-g done done

@tarrinneal

Copy link
Copy Markdown
Contributor Author

@stuartmorgan-g While I technically need your review. Gemini said: "You have essentially achieved the holy grail of cross-platform plugin design. You maintained strict, identical behavioral output while perfectly adapting to the efficiency constraints and memory safety rules of each specific compiler."

So I think I'm set.

@tarrinneal tarrinneal added the CICD Run CI/CD label Mar 12, 2026

@stuartmorgan-g stuartmorgan-g left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread packages/pigeon/example/app/macos/Runner/messages.g.m Outdated
@tarrinneal tarrinneal added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 20, 2026
@tarrinneal tarrinneal added CICD Run CI/CD and removed CICD Run CI/CD labels Mar 25, 2026
@auto-submit
auto-submit Bot merged commit 3e15247 into flutter:main Mar 25, 2026
81 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 25, 2026
…Kotlin, java, and Swift, adds equality in other languages (flutter/packages#11140)
github-merge-queue Bot pushed a commit to flutter/flutter that referenced this pull request Mar 25, 2026
flutter/packages@8dcfd11...5909bdd

2026-03-25 [email protected] [ci] add more
permissions for create-pull-request (flutter/packages#11302)
2026-03-25 [email protected] [various] Add
`unintended_html_in_doc_comment` to analysis options
(flutter/packages#11303)
2026-03-25 [email protected] Use deprecated dependency until legacy
renderer is removed (flutter/packages#11185)
2026-03-25 [email protected] [in_app_purchase_storekit] Address flaky
tests (flutter/packages#11270)
2026-03-25 [email protected] [google_maps_flutter] Fix A2A iOS
builds (flutter/packages#11290)
2026-03-25 [email protected] [mustache_template] Fix broken README
link (flutter/packages#11306)
2026-03-25 [email protected] [ci] Add a workflow to auto-remove
CICD label (flutter/packages#11301)
2026-03-25 [email protected] [various] Convert plugin builds to
Kotlin gradle (flutter/packages#11172)
2026-03-25 [email protected] [webview_flutter_platform_interface] Add
support for getting cookie (flutter/packages#11037)
2026-03-25 [email protected] [cupertino_icons] Remove empty Dart
file (flutter/packages#11308)
2026-03-25 [email protected] [camera] Regenerate iOS example with
Swift (flutter/packages#11283)
2026-03-25 [email protected] [pigeon] Optimize data class equality
and hashing in Dart, Kotlin, java, and Swift, adds equality in other
languages (flutter/packages#11140)
2026-03-25 [email protected] [two_dimensional_scrollables] Fix span
border decorations in flipped cross axes (flutter/packages#11334)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected] on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
okorohelijah pushed a commit to okorohelijah/packages that referenced this pull request Mar 26, 2026
…va, and Swift, adds equality in other languages (flutter#11140)

This PR optimizes the generated equality (==) and hashing (hashCode/hash) logic for data classes across All languages. These have been bothering me for a while, and I wanted to break out a new pr before the NI code is in review.
mboetger pushed a commit to mboetger/flutter that referenced this pull request Mar 26, 2026
…er#184123)

flutter/packages@8dcfd11...5909bdd

2026-03-25 [email protected] [ci] add more
permissions for create-pull-request (flutter/packages#11302)
2026-03-25 [email protected] [various] Add
`unintended_html_in_doc_comment` to analysis options
(flutter/packages#11303)
2026-03-25 [email protected] Use deprecated dependency until legacy
renderer is removed (flutter/packages#11185)
2026-03-25 [email protected] [in_app_purchase_storekit] Address flaky
tests (flutter/packages#11270)
2026-03-25 [email protected] [google_maps_flutter] Fix A2A iOS
builds (flutter/packages#11290)
2026-03-25 [email protected] [mustache_template] Fix broken README
link (flutter/packages#11306)
2026-03-25 [email protected] [ci] Add a workflow to auto-remove
CICD label (flutter/packages#11301)
2026-03-25 [email protected] [various] Convert plugin builds to
Kotlin gradle (flutter/packages#11172)
2026-03-25 [email protected] [webview_flutter_platform_interface] Add
support for getting cookie (flutter/packages#11037)
2026-03-25 [email protected] [cupertino_icons] Remove empty Dart
file (flutter/packages#11308)
2026-03-25 [email protected] [camera] Regenerate iOS example with
Swift (flutter/packages#11283)
2026-03-25 [email protected] [pigeon] Optimize data class equality
and hashing in Dart, Kotlin, java, and Swift, adds equality in other
languages (flutter/packages#11140)
2026-03-25 [email protected] [two_dimensional_scrollables] Fix span
border decorations in flipped cross axes (flutter/packages#11334)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected] on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
ahmedsameha1 pushed a commit to ahmedsameha1/flutter that referenced this pull request Apr 14, 2026
…er#184123)

flutter/packages@8dcfd11...5909bdd

2026-03-25 [email protected] [ci] add more
permissions for create-pull-request (flutter/packages#11302)
2026-03-25 [email protected] [various] Add
`unintended_html_in_doc_comment` to analysis options
(flutter/packages#11303)
2026-03-25 [email protected] Use deprecated dependency until legacy
renderer is removed (flutter/packages#11185)
2026-03-25 [email protected] [in_app_purchase_storekit] Address flaky
tests (flutter/packages#11270)
2026-03-25 [email protected] [google_maps_flutter] Fix A2A iOS
builds (flutter/packages#11290)
2026-03-25 [email protected] [mustache_template] Fix broken README
link (flutter/packages#11306)
2026-03-25 [email protected] [ci] Add a workflow to auto-remove
CICD label (flutter/packages#11301)
2026-03-25 [email protected] [various] Convert plugin builds to
Kotlin gradle (flutter/packages#11172)
2026-03-25 [email protected] [webview_flutter_platform_interface] Add
support for getting cookie (flutter/packages#11037)
2026-03-25 [email protected] [cupertino_icons] Remove empty Dart
file (flutter/packages#11308)
2026-03-25 [email protected] [camera] Regenerate iOS example with
Swift (flutter/packages#11283)
2026-03-25 [email protected] [pigeon] Optimize data class equality
and hashing in Dart, Kotlin, java, and Swift, adds equality in other
languages (flutter/packages#11140)
2026-03-25 [email protected] [two_dimensional_scrollables] Fix span
border decorations in flipped cross axes (flutter/packages#11334)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected] on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
creatorpiyush pushed a commit to creatorpiyush/packages that referenced this pull request Jun 10, 2026
…va, and Swift, adds equality in other languages (flutter#11140)

This PR optimizes the generated equality (==) and hashing (hashCode/hash) logic for data classes across All languages. These have been bothering me for a while, and I wanted to break out a new pr before the NI code is in review.
Nakiha pushed a commit to Nakiha/VoidPlayer-Flutter that referenced this pull request Sep 28, 2026
flutter/packages@8dcfd11...5909bdd

2026-03-25 [email protected] [ci] add more
permissions for create-pull-request (flutter/packages#11302)
2026-03-25 [email protected] [various] Add
`unintended_html_in_doc_comment` to analysis options
(flutter/packages#11303)
2026-03-25 [email protected] Use deprecated dependency until legacy
renderer is removed (flutter/packages#11185)
2026-03-25 [email protected] [in_app_purchase_storekit] Address flaky
tests (flutter/packages#11270)
2026-03-25 [email protected] [google_maps_flutter] Fix A2A iOS
builds (flutter/packages#11290)
2026-03-25 [email protected] [mustache_template] Fix broken README
link (flutter/packages#11306)
2026-03-25 [email protected] [ci] Add a workflow to auto-remove
CICD label (flutter/packages#11301)
2026-03-25 [email protected] [various] Convert plugin builds to
Kotlin gradle (flutter/packages#11172)
2026-03-25 [email protected] [webview_flutter_platform_interface] Add
support for getting cookie (flutter/packages#11037)
2026-03-25 [email protected] [cupertino_icons] Remove empty Dart
file (flutter/packages#11308)
2026-03-25 [email protected] [camera] Regenerate iOS example with
Swift (flutter/packages#11283)
2026-03-25 [email protected] [pigeon] Optimize data class equality
and hashing in Dart, Kotlin, java, and Swift, adds equality in other
languages (flutter/packages#11140)
2026-03-25 [email protected] [two_dimensional_scrollables] Fix span
border decorations in flipped cross axes (flutter/packages#11334)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected] on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants