Skip to content
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

Use Dart 2.14's new hashing functions #129

Closed
hacker1024 opened this issue Oct 29, 2021 · 3 comments
Closed

Use Dart 2.14's new hashing functions #129

hacker1024 opened this issue Oct 29, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@hacker1024
Copy link

hacker1024 commented Oct 29, 2021

Dart 2.14 adds new hashing methods like Object.hash (uses optional arguments for up to 20 objects) and Object.hashAll (uses a list for a large or variable number of objects).

The reasoning behind this addition to the language can be found at dart-lang/sdk#11617.
Also see https://dart-review.googlesource.com/c/sdk/+/73360.

Using the built-in hashing functions would allow this package to have a smaller footprint and fit in with everything else if the Dart maintainers ever decide to change or optimise the hashing algorithm.

@felangel
Copy link
Owner

Hi @hacker1024 👋
Thanks for opening an issue!

I’m aware of Object.hash and Object.hashAll however last time I checked replacing the current implementation with Object.hashAll breaks the existing unit test suite.

I’ll take another look in the next week but if you’d like feel free to open a pull request. Thanks!

@felangel felangel added the enhancement New feature or request label Oct 29, 2021
@felangel felangel added this to To do in equatable Oct 29, 2021
@hacker1024
Copy link
Author

I've just had a go at implementing this, but it's more complicated than I initially expected due to the recursive collection hashing functionality.

I have a question: Why not use _equality's hash method in mapPropsToHashCode? It seems to do the same thing as the existing implementation, although I'm not sure if it uses the same algorithm.

@felangel
Copy link
Owner

I'm closing this for now as Object.hashAll isn't functionally equivalent to the current implementation.

@felangel felangel moved this from To do to Done in equatable Oct 14, 2023
@felangel felangel removed this from Done in equatable Oct 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants