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

Small performance update for rendering list items #1476

Merged
merged 5 commits into from
Feb 8, 2024

Conversation

vnbaaij
Copy link
Collaborator

@vnbaaij vnbaaij commented Feb 7, 2024

Instead of doing a type check (using reflection) on each item in the list of items (if supplied), only do this for the first item in the list.

src/Core/Components/List/ListComponentBase.razor Outdated Show resolved Hide resolved
if (prop is not null)
{
(Icon Value, Color? Color, string? Slot) = ((Icon Value, Color? Color, string? Slot)) prop.GetValue(item)!;
(Icon Value, Color? Color, string? Slot) = ((Icon Value, Color? Color, string? Slot))prop.GetValue(item)!;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To validate, but if your Option<TType> class implements this interface, you could cast your object and have access to these properties:

var optionIcon = item as IOptionIcon;
var value = optionIcon?.Icon.Value;
...
internal interface IOptionIcon
{
    (Icon Value, Color? Color, string? Slot) Icon { get; set; }
}

@vnbaaij vnbaaij merged commit 58bfbd7 into dev Feb 8, 2024
4 checks passed
@vnbaaij vnbaaij deleted the users/vnbaaij/list-rendering branch February 8, 2024 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants