-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Optimize performance of Flex.Item #20034
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
|
Hey there @symbiogenesis! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
|
/azp MAUI-UITests-public |
|
Command 'MAUI-UITests-public' is not supported by Azure Pipelines. Supported commands
See additional documentation. |
|
/azp run MAUI-UITests-public |
|
Azure Pipelines successfully started running 1 pipeline(s). |
| } | ||
|
|
||
| public void Add(Item child) | ||
| public new void Add(Item child) |
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.
Inherit from List and uses the new on base methods is dangerous, if at some part of the code Item is cast to List<Item>, just the base.Add will be executed (The same for InsertAt). I believe having this class inherit from IEnumerable is to avoid this pitfall.
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.
That is a fair point. Although, Flex.Item is an internal class and I don't see anywhere in the codebase that it is being cast to a list.
Probably some of the same benefits could be attained by just figuring out how to remove the FlexExtensions file and simply using the built-in list functions of the Children property directly.
Of course, the approach of this PR also simplifies the code a bit.
Flex.Item was an IEnumerable but internally stored a collection of Children as a List.
It seemed much simpler to just inherit from a list and remove all of the IEnumerable implementation and related extension methods.
Added a benchmark to confirm the suspicion.
Before:
After: