Implement ==/hashCode for ViewConfiguration, avoid unnecessary layer creation/replacement#81928
Merged
fluttergithubbot merged 6 commits intoflutter:masterfrom May 7, 2021
Merged
Conversation
…creation/replacement
goderbauer
approved these changes
May 5, 2021
| } | ||
|
|
||
| @override | ||
| bool operator==(Object other) { |
Member
There was a problem hiding this comment.
nit: space between operator and ==?
| import 'rendering_tester.dart'; | ||
|
|
||
| void main() { | ||
| // Create non-const instances, otherwise tests pass even if the |
Member
There was a problem hiding this comment.
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)
Contributor
Author
There was a problem hiding this comment.
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); |
yjbanov
approved these changes
May 6, 2021
| } | ||
|
|
||
| @override | ||
| int get hashCode => hashValues(size.hashCode, devicePixelRatio); |
Contributor
There was a problem hiding this comment.
IIRC hashValues already calls .hashCode on its arguments, so passing size.hashCode becomes size.hashCode.hashCode, which, while not wrong, is unnecessary.
Contributor
|
This pull request is not suitable for automatic merging in its current state.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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