-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Implement ==/hashCode for ViewConfiguration, avoid unnecessary layer creation/replacement #81928
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
Conversation
…creation/replacement
goderbauer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| } | ||
|
|
||
| @override | ||
| bool operator==(Object other) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: space between operator and ==?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| import 'rendering_tester.dart'; | ||
|
|
||
| void main() { | ||
| // Create non-const instances, otherwise tests pass even if the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a test case for this to encode that two ViewConfiguration returned by this are not identical? (could be part of the ViewConfiguration == and hashCode test)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also indirectly covered in the replace root layer test, but added a more explicit one to the == and hashcode test.
| final ViewConfiguration viewConfigurationA = createViewConfiguration(); | ||
| final ViewConfiguration viewConfigurationB = createViewConfiguration(); | ||
|
|
||
| expect(viewConfigurationA == viewConfigurationB, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test != cases ?
yjbanov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM if LGT @goderbauer
| } | ||
|
|
||
| @override | ||
| int get hashCode => hashValues(size.hashCode, devicePixelRatio); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC hashValues already calls .hashCode on its arguments, so passing size.hashCode becomes size.hashCode.hashCode, which, while not wrong, is unnecessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are correct
|
This pull request is not suitable for automatic merging in its current state.
|

Part of a quest to make layer usage more sensible, to resolve #81514
Without this change, we unnecessarily replace/recreate the root layer every time we get an update about view configuration, even if the configuration has not actually changed.
I promise I read and fulfilled all the boxes, I'm just lazy about adding x's all over