equatable
equatable copied to clipboard
Use Dart 2.14's new hashing functions
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 https://github.com/dart-lang/sdk/issues/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.
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!
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.
I'm closing this for now as Object.hashAll
isn't functionally equivalent to the current implementation.