Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix KeySet<T> (and LogicalKeySet) hashCode calculation #38936

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 23, 2019

Conversation

gspencergoog
Copy link
Contributor

@gspencergoog gspencergoog commented Aug 21, 2019

Description

This fixes the hashCode calculation for KeySet<T> so that it doesn't depend on the insertion order of the keys in the set.

The fix involves switching from Set<T> to HashSet<T> internally, so that the iteration order is stable around the hash values of the inserted keys, and not the insertion order. This matters when hashList is called in KeySet<T>.hashCode to build the hash value of the contents of the internal set.

Related Issues

#38919

Tests

  • Modified the "LogicalKeySet works as a map key." test to include tests for the hashCode calculation both from the up-to-four key constructor, and the fromSet constructor.

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.
  • I checked all the boxes!

Breaking Change

Does your PR require Flutter developers to manually update their apps to accommodate your change?

  • No, this is not a breaking change.

@fluttergithubbot fluttergithubbot added the framework flutter/packages/flutter repository. See also f: labels. label Aug 21, 2019
@gspencergoog gspencergoog changed the title Fix KeySet<T> (and LogicalKeySet, PhysicalKeySet) hashCode calculation Fix KeySet<T> (and LogicalKeySet) hashCode calculation Aug 21, 2019
Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

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

LGTM

@gspencergoog gspencergoog merged commit 055c548 into flutter:master Aug 23, 2019
@gspencergoog gspencergoog deleted the key_set_hash branch October 9, 2019 23:54
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants